Feeds:
Posts
Comments

Posts Tagged ‘Ruby on Rails’

The first thing is, we can have something like inline exception handlers. rescue_from ActiveRecord::RecordNotFound do render :file => ‘/bad_record’, :status => 404 end Block can even take have an argument for exception object. rescue_from ActiveRecord::RecordInvalid do |exception| render :action => (exception.record.new_record? ? ‘new’ : ‘edit’) end The above method will be helpful if we use [...]

Read Full Post »

flash[:notice] is meant only for redirect action, because the message is only cleared after the redirected view request. So if you don’t redirect the request, and you click on the next request, that message will still be displayed. But sometimes, we just want to display custom error messages only for current request without the redirection [...]

Read Full Post »

Rails comes with a script/runner script that can be used to run the code in your Rails app. There’re many ways to organize your code to let this runner script execute it, but one obvious way is to write the code as a model’s action. Here are quick steps for doing this: 1. Insert the [...]

Read Full Post »

Read Full Post »

Debugging Rails View

<% if ENV['RAILS_ENV'] == ‘development’ %> <div id=”debug_info”> <%= debug session %> <%= debug params %> </div> <% end %>

Read Full Post »

« Newer Posts