Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Jon Pascoe's Profile

GitHub User: pacso

Site: www.jonpascoe.co.uk

Comments by Jon Pascoe

Avatar

Alternatively, set the default format in the routes.rb file:

routes.rb
Raffler::Application.routes.draw do
  resources :entries, defaults: { format: :json }

  root to: 'raffle#index'
end
Avatar

Fairly simple to achieve.

Assuming your Player model has_many :salaries, you can enable the expected f.fields_for :salaries behaviour in your form by adding the appropriate attributes:

ruby
class PlayersForm
  include ActiveModel::Model

  def persisted?
    false
  end

  attr_accessor :salaries, :salaries_attributes

  def initialize(player)
    @player = player
    @salaries = player.salaries
  end
end
Avatar

I think the routes.rb code needs to change for Rails 3 apps to something like this:

resources :orders do
get 'express', :on => :collection
end

and then use the express_orders_path rather than express_new_order_path