Reputation: 3542
Here is my use case, in bullet points so its nice and easy to follow:
Devise
gem template mainly.)Submit
, of course it is the Users
controller being used here, because Admin is of type User.create
method. I want to create
a new Student or Teacher model. They both have their own controllers, with their own create
methods, but how do I call them from the User controller? Or, if that is bad practice, I guess more generally my question is how do I create one of these new models instead of the User model?Thanks!
Upvotes: 0
Views: 176
Reputation: 2289
If i understood your question correctly, you can check your params for type of new user from your radio box, and then simply call some private method and pass params into, that will create new resource depending on params.
For example
Assume you have in your params key with name of entity
. You do post on create#users
def create
if create_new_resource(params)
redirect_to some_path
else
render 'new'
end
end
private
def create_new_resource(params)
"#{params[:entity].create(params)}"
end
Just for as a start version. You have to do some changes aswell
Upvotes: 2