Reputation: 1132
I have 4 different groups of data that I want to: create, update, delete
I want to use one action for each function, using a variable, but can't get it to work.
For example:
def create
@type = params['type'] # use an outside ajax request to decide type
@type.create(:title => 'new title') # create a new table using that type
end
Upvotes: 1
Views: 83
Reputation: 159105
Have you tried constantize
?
def create
@type = params['type'].constantize # use an outside ajax request to decide type
@type.create(:title => 'new title') # create a new table using that type
end
Upvotes: 2