Rails 3.1 migrations drops timestamp in migration filenames - ruby-on-rails

I am trying to upgrade an application from Rails 3.0.7 to 3.1.1. When I try to run a migration under 3.1.1, the migration file gets generated but without the leading timestamp. For example:
$ rails g migration add_foo_to_users foo:boolean
invoke active_record
create db/migrate/_add_foo_to_users.rb
The contents of the generated file look correct (with the new cool change method), but the migration file seems like it should be named more like db/migrate/20111012002448_add_foo_to_users.rb.
I suspect that I am missing something simple, but spent all weekend trying to figure out what it is. Search shows nothing helpful that I found. Migrations have been working all along before this, so something in the steps I took to upgrade seems to have broken it. Any suggestions of where to look would be appreciated. Thanks.

I have traced this issue down and fixed it in the GateGuru fork of also_migrate. A pull request is pending for merge back into also_migrate.
For anyone bitten by this in the interim, the pull request is at: https://github.com/winton/also_migrate/pull/10
You can also install from my fork via Bundler to fix the issue:
gem 'also_migrate', '0.3.5', :git => 'git#github.com:GateGuru/also_migrate.git', :branch => '8-fix-rails-3_1-timestamps'

Just in case anyone ends up here after hitting the same problem. After copying the entire application to another directory, and comparing to a clean install of a new Rails application, I narrowed this down to the configuration block for the also_migrate gem. When I comment out the lines for this configuration, the migration files were generated properly. Uncommenting the same lines recreates the error.

Related

How to upgrade Administrate gem

I have a Rails 4 app with Thoughtbot Administrate for the admin part.
Recently I tried to upgrade from version 0.1.2 to 0.1.4, but I got this error: cannot load such file -- administrate/fields/base.
It was triggered from a custom field file, so I tried to run rails g administrate:install, which asked me to overwrite all my administrate controllers and dashboards.
Now, I have made customizations to those files, so I opted not to overwrite them, but then I ended up with the same error as before.
Next, I made another branch to test and let administrate to overwrite my controllers and dashboards, and this time it worked!
So, I think the question is, what is the process to upgrade the gem without losing my customizations?
Is there any task I can run in order to "register" the updated gem, like rake administrate:upgrade or so?
Thanks!
Found out the error.
Seems that administrate/fields/base is now administrate/field/base, so this subtle update in the Administrate gem code is breaking my custom field.
Anyway, I think a potentially breaking update to the gem's code should be advertised and maybe even change the mayor version number, so I'll rise an issue in github for this one.

Rails 4.2 + Ember => unexpected identifier

I'm following Vic Ramon's tutorial. I tried to use the latest version of Rails and Ember-source and I get the following error when visiting home page:
After clicking on link next to error I get this:
How can I fix that?
I ran the following commands:
rails g ember:bootstrap -n App --javascript-engine coffee
rails g ember:install
I removed turbolinks. I also created home controller and an empty view for home#index. Root is set to home#index. Also created following view file:
// app/assets/javascripts/templates/application.js.emblem
h1 Hello World
outlet
Ember gems im using:
Using emblem-source 0.3.18
Using ember-data-source 1.0.0.beta.14.1
Using ember-rails 0.16.1
Using emblem-rails 0.2.2
This could be due to some version incompatibilities between your versions of ember-related gems, as there were quite substantial changes in recent versions of ember (e.g. introduction of HTMLBars, etc.)
Your best bet is to clone the original repo and then try to upgrade individual gems and check if it still works after each upgrade. This way you will be able to identify the troubling gem.
I have verified that the original repo code indeed works with the versions of gems in its current Gemfile.lock.
If you are starting a new Rails + Ember app, ember-cli-rails is probably the way to go, giving you the best of both worlds.
Emblem was the culprit. Replacing .emblem with .handlebars fixed the problem. I tried the tip from emblem-rails git page and icluded
gem "emblem-source", github: "machty/emblem.js"
but that didn't change anything.
I also followed this tutorial (alongside a few others) and I encountered several issues alongside the way ranging from handling templates to setting up the JSON API. I don't see your entire source code so I cannot pinpoint the exact problem. However, it seems that we have similar projects, so you can compare your code to my blog project source code and see what is causing these issues. Comparing to Ramon's tutorial, my blog has implemented everything until chapter 15.
https://github.com/Deovandski/Fakktion/tree/Ember-Rails
If you are a beginner like myself, then I recommend avoiding CoffeeScript and Emblem and sticking to Javascript as much as possible for the first months because you will find more resources and examples. Also, let me know if you need assistance in setting up the project as I used .gitignore to hide things like secrets.yml

Rails will not let me destroy scaffolding from nifty generator

I was following one of the railscasts tutorials and decided to install nifty generators. Well, being a rails noob I didn't realize that the way parameters are handled changed. Now I can't undo any of my changes. So far I managed to roll back the database but every time I try to run
rails destroy nifty:scaffold mymodel
I get the error message
attr_accessible is extracted out of rails into a gem. Please use new recommended protection model for params(strong_parameters) or add protected_attributes to your Gemfile to use old one.
So I did. I added
gem 'protected_attributes'
and ran
bundle install
Then I tried to destroy it and it errored out again. I really hope nifty didn't just screw up my project. Can anyone help?
Um, this not a real solution, but a possible workaround: if the output of the rails generate nifty:scaffold mymodel command is still in your terminal buffer, you could manually delete the files it created.
And if the output isn't available, you could do rails generate nifty:scaffold mymodel2 in order to see what files nifty:scaffold created before manually deleting the corresponding files for mymodel.
Not elegant, but it might get you over the hump.

Where can I find comatose-rubyisbeautiful tutorial?

Now I am trying to convert Rails2 application into Rails3 one.
And I used comatose as CMS in old project, but now I can not find Rails3 compatible comatose version.
Instead, I did find comatose-rubyisbeautiful gem.
So I added it in my Gemfile, and installed.
And executed the command "rails generate comatose".
It generated initializers/comatose.rb and new migration file.
Then the next step is to execute migration, by "rake db:migrate".
But it shoots me an error, like the following.
"Uninitialized constant Comatose" in config/initializers/comatose.rb
Is there anything wrong?
Please help me with this.
I am the author of the fork. I haven't touched it in years. I hope you have found an alternative since September. If not, I can help get you going with what is there, but I am not sure that I will actively maintain the gem. There has not been much interest other than the one company for whom I brought the old Comatose up to date.

Getting tables to work is RadRails?

When I manually enter tables into the .rb file in the migrate folder nothing shows up. I have followed a few different "how to's" but I can't get the tables to show up when I preview my work. I can however get one table to show up if I create it in the parameters when generating a scaffold, but that's one table. I have Rails version 2.3.4 and version 1.2.3 installed on my lame Windows Vista. I have tried using both versions multiple times. I am also trying to follow the Ruby on Rails for Dummies book, but it seems a little outdated. Any tips on getting tables to work? Its supposed to be really simple and take "just minutes" to complete this simple app. Maybe something didn't install right? Maybe a better book?
Just want to make sure you're using all the tools available to you:
To generate a migration file:
./script/generate MigrationFileName
Take a look at the Database Migrations Guide from the official Rails Guides for the correct syntax and options for creating a migration file.
Once you've created your migration, you need to run the following:
rake db:migrate
This will populate the database with the information specified in the migration file.

Resources