migrating-from-ruby-on-rails

Redirects

Redirect_to in RoR becomes redirect in Merb, redirect in Merb requires a String, not a Hash. To solve this, use url(...). Example:

redirect url(:controller => 'comment', :action => 'new')

Partials

Rendering partials in Merb uses its own function call, partial. Partial can take a symbol for an action which is in the controller’s view folder or a string if you wish to fully qualify the location of the partial. For the classical rendering of a shared _form.html.erb between ‘new’ and ‘edit’ CRUD operations:

partial :form
To specify variables which will be accessible as local in the partial:

partial "/shared/foo_rendering", :foo => bar

Specs

Unlike RoR tests, Merb specs do not dump and recreate the test environment automatically; instead of using ‘fixtures :foo, :bar’, use ‘rake db:fixtures:load’ to load all your fixtures (which should be in tests/fixtures even if you’re using specs)

Methods names.


before_filter => before
after_filter => after
redirect_to => redirect
url_for => url

Edit Page | History | Version: