rails db:migrate giving warning and not creating any table - ruby-on-rails

When I start doing code on (see image below) rails I saw rails guide to getting start with it. There's a command rails db:migrate for creating table and stuff. But its giving only warning and not creating any table.

The code has executed successfully and there are no issues with it. The warnings are because either your code, or some of the gems you have used in the code contain some methods that are deprecated.
If the warning comes from your code, try to fix them. If it is from any dependency, then watch for updates, keep the gems updated, or you can also write to the gem developer to fix these warnings.

Related

Error Installing importmap on rails application

I am having troubling setting up an existing rails application. I am supposed to set up importmap but it is giving me trouble.
If having trouble viewing the uploaded pic, it says "rails aborted!
Don't know how to build task 'importmap:install'"
Rails error pic
If I run "rails --tasks" importmap:install does show up.
rails --tasks output snippet
As per the attached screenshot of the task list, the actual task name apparently is called app:importmap:install instead of importmap:install.
I'm not sure why that might be the case, though. It seems to me like you might (accidentally?) be working on a Rails engine instead of an actual app?

Rails 6 testing - "Could not find table" error on table that was previously dropped

I'm trying to write some test for my rails app. On the first line of the definition for my very first test, rails throws this unhelpful error:
Error:
LabStationTest#test_prioritize_students_basic:
ActiveRecord::StatementInvalid: Could not find table 'equipment'
equipment was a table that I deleted in a previous migration. I have no more references to it in my code, and have since then run commands like rails db:drop, rails db:migrate, rails db:reset, and rails db:test:prepare multiple times to no avail.
I tried searching project-wide for the word "equipment", and I did find a CREATE TABLE IF NOT EXISTS "equipment" statement left over in structure.sql for some reason. I'm not sure if that's relevant or how to safely delete it, and I couldn't find any other references to that term.
Rails is great but it absolutely drives me nuts how the codegen scatters hidden references all over the place. Anyone know what I should do next?
Shortly after posting this, I discovered outdated models left over in test/fixtures - this seems to be the culprit.
Errors like this are my biggest frustration with Rails, they cast doubt on the "convention over configuration" paradigm for me. It wouldn't be half as bad if they at least included a stack trace with the error messages, but even with the -v flag they tend to provide little useful information

Rails App Suddenly Not Working

I was just working on one of my models when my Rails app would not work anymore. Even typing out commands like rails -v, rails, c, bundle install, or any command is giving out the same error. What's causing it is a syntax error on the file fileutils.rb. I'm using the ruby version ruby-1.9.3-p551.
First set of error messages.
(I have not included the middle part of the error messages.)
Last set of error messages.
I do not understand as to what caused the file fileutils.rb to be modified or be syntax errored.
I have modified the fileutils.rb by copy-pasting lines 309-421 from another fileutils.rb file.
I got it working again but I am still confused as to what corrupted my file.

How to actually use rails-settings?

I'm trying to use rails-settings gem but i'm not sure how to do that.
I've added ledermann-rails-gem gem to Gemfile, runned bundle install, generated a migration based on what's written in wiki, runned rake db:migrate, restarted a server and now, when i'm trying to do anything from rails-settings wiki, i'm getting an error.
Let's say i want to create new variable so i'm putting this code to my controller:
Settings.foo = "bar"
It gives me the following error:
uninitialized constant ApplicationController::Settings
I'm quite 'fresh' in rails development and probably there is some small thing which wasn't mentioned in the wiki because it's obvious (but not for me!). Any help would be appreciated

Rails Tests Fail With Sqlite3

I seem to be getting a strange error when I run my tests in rails, they are all failing for the same reason and none of the online documentation seems particularly helpful in regards to this particular error:
SQLite3::SQLException: cannot rollback - no transaction is active
This error is crippling my ability to test my application and seems to have appeared suddenly. I have the latest version of sqlite3 (3.6.2), the latest sqlite3-ruby (1.2.4) gem and the latest rails (2.1.1).
Check http://dev.rubyonrails.org/ticket/4403 which shows a workaround. Could that be the problem you are encountering?
I had this problem once but with MySQL. Turned out I hadn't created the test database. Doh! Rails and sqlite creates them automatically I believe (at least it does in windows).
Are trying to do in memory testing? If not does the test database exist?
I got this error when running a test with the last statement being a click on a form submit. Once I did an assertion or should test, the test closed properly, and I didn't have to rerun the rake db:test:prepare
Thanks for the help. I actually ended up just deleting the rails folder and checking back out the last working copy from version control. I've made the identical changes and this problem hasn't reappeared, so either I messed up or rails had some sort of hiccup. Thankfully I had version control :-)

Resources