ruby-on-rails-3edit-in-place

Rails best_in_place gem with nested resource


Does anyone know if it is possible (and, if so, what the syntax is) for using a nested resource with the best_in_place gem?

My routes.rb looks something like this

resources :users do
  resources :goals 
end

I would like to edit the :description field of the goal, but the code in my view for

<%= best_in_place [@user, @goal], :description %>

gives a NoMethodError saying

undefined method `description' for #<Array:0x20e0d28> 

Using

<%= best_in_place @goal, :description %>

give me an undefined method error also because there is no goal_path

I can get the gem to work for @user (the non nested resource) field without problems.

I'm running Rails 3.1.1, Ruby 1.9.2, best_in_place 1.0.4


Solution

  • I figured it out.

    I needed to set the path option in the call like so

    <%= best_in_place @goal, :description, :path => user_goal_path %>
    

    It works like a champ now!