Weird routing error

4 views
Skip to first unread message

Paul Singh

unread,
Nov 6, 2009, 6:58:41 PM11/6/09
to Compass
Hey guys,

I've been bumping my head against this weird routing error... anyone
have any ideas why it's trying to render the create view (which, for
obvious reasons, doesn't exist anyway)?

Processing LettersController#create (for 127.0.0.1 at 2009-11-06
18:53:31) [POST]
Parameters: {"authenticity_token"=>"25ugvvfHKwu7/c4rSmoVae0YkmFGeF/
VeEXGMG0XHEY=", "letter"=>{"content"=>"", "email"=>""}, "address"=>
{"city"=>"", "name"=>"", "zip"=>"", "street1"=>"", "street2"=>"",
"state"=>""}}

ActionView::MissingTemplate (Missing template letters/create.erb in
view path app/views):
haml (2.2.10) lib/sass/plugin/rails.rb:19:in
`process_without_compass'
vendor/gems/chriseppstein-compass-0.8.17/lib/compass/app_integration/
rails/action_controller.rb:7:in `process'

Rendering rescues/layout (internal_server_error)

And the create method...

def create
@letter = Letter.new(params[:letter])

@letter.save do |result|
if result
redirect_to show_letter_url(@letter)
else
render :action => :new
end
end
end

Thanks!

Chris Eppstein

unread,
Nov 6, 2009, 7:09:08 PM11/6/09
to compas...@googlegroups.com
There's no compass issue here. Just a misunderstanding of the active record API in Ruby on rails.

You're passing a block to ActiveRecord::Base#save which doesn't give any error, but is also completely discarded.

you wanted to say:

if @letter.save

  redirect_to show_letter_url(@letter)
else
  render :action => :new
end

The reason that it's looking for the create view is that's the default behavior if no rendering happened during the action.
Reply all
Reply to author
Forward
0 new messages