To migrate your database in production environment simply run the following command.
rake db:migrate RAILS_ENV=production
After upgrading from Rails 2.0.2 to 2.3.5 my WEBrick server in NetBeans started printing the following message on its log and the application would not connect to the database.
The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
I installed the refered gem but would still have the same problem when starting WEBrick, even after restart of the IDE.
After upgrading from Rails 2.0.2 to Rails 2.3.5 I got the following error message on startup of the server:
`send': undefined method `cache_template_extensions=' for ActionView::Base:Class (NoMethodError)
The solution is as simple as removing (or commenting out) the property 'cache_template_extensions' from 'configuration/environments/development.rb' as it no longer exists in rails 2.3.5.
If you are using Netbeans as a development environment for creating Ruby on Rails software, you should know how to debug your application. Using these out-of-the-box frameworks are really great when it comes to the speed of the development however, whenever you face strange behavior, debugging is the key.
If you need to update any gem in your system and you get some strange error message like the one below, maybe all you need to do is upgrade your RubyGems component.
ERROR: While executing gem ... (Gem::RemoteSourceException)
HTTP Response 403
I got the above error message when running the following command:
gem update --system
Another symptom that you need to upgrade your RubyGem is if you notice that the system responds different versions for your components:.
For instance, if you get this...
I found this nice article which proposes a ready-to-use debug popup window. All you have to do is add a simple command at the end of your application layout and a popup will show all the information regarding the request, session, response, flash variables and more.
Quick way to debug your web application.
Cheers!
I wrote an article the other day stating that I had no idea why someone would call a Helper method from inside a Controller in Rails.
I just found a reason. Here is what I needed to do:
Sometimes all you want is to display a flash message for the current request template, i.e. it should not propagate to the next action. For example, I had an action where I wanted to warn the user that he had already processed a file:
def parse
@upload = Upload.find(params[:id])
if (@upload.processed_at)
flash[:warning] = "This file has already been processed at " + @upload.processed_at.to_s(:long)
end
end
Some common tasks in the development business are done no matter the programming language you use. Debugging is one of those tasks. While developing web applications I often need to debug the View layer and it is kind of a tedious job to write while loops to inspect variables values, for example.
Rails provides some interesting helper methods for your views:
debug
This helper method will return the information about any object in YAML format, which is very human readable. To use this command, just type:
Recent comments
5 days 3 hours ago
3 weeks 3 days ago
4 weeks 9 hours ago
4 weeks 6 days ago
5 weeks 5 days ago
7 weeks 1 day ago
8 weeks 6 days ago
14 weeks 2 days ago
18 weeks 5 days ago
26 weeks 15 hours ago