3

I have the following model:

class Action < ActiveRecord::Base
  # model code stuff
end

In the controller, I can do something like that:

class ActionsController < ApplicationController
  # super simple update
  def update
    @action = Action.find(params[:id])
    @action.update_attributes(params[:action])
  end
end

Is it possible to make my Action model to be represented by 'something_action' in params array without renaming the model itself? I.e. so I can retrieve it like that:

@action.update_attributes(params[:something_action])

Any help would be appreciated?

alexs333
  • 12,143
  • 11
  • 51
  • 89

2 Answers2

4

In your form_for use :as => :some_other_params_name

form_for(@action, :as => :different
dasnixon
  • 988
  • 7
  • 18
1

If you are using form_for, you can change it to

form_for :something_action, @action do |f|

so it uses :something_action as the name of the params

jvnill
  • 29,479
  • 4
  • 83
  • 86