On Tue, Nov 17, 2009 at 04:16:46PM -0800, Eric wrote:

> routes.rb:
> map.resources :properties, :has_many => :notes
> <%= link_to 'New note', new_property_note_path(@property) %>

I did that, and it works for views (e.g. "/properties/4/notes/2"). However, I
get this error when I try to actually create a note:

    ActiveRecord::RecordNotFound in NotesController#create
    Couldn't find Property without an ID

In my notes_controller.rb, I have:

  def new
    @note = Note.new
    respond_to do |format|
      format.html
    end
  end

  def create
    @note = Property.find(params[:id]).notes.create(params[:note])
    @note.user_id = current_user.id

    respond_to do |format|
      if @note.save
        flash[:notice] = 'Note was successfully created.'
        format.html { redirect_to property_path @note.property_id }
      else
        format.html { render :action => "new" }
      end
    end
  end

So, something is still not quite right. How is @note supposed to get the
property id from params here?

-- 
"Oh, look: rocks!"
        -- Doctor Who, "Destiny of the Daleks"

--

You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=.


Reply via email to