Ruby on Rails 4: New action in modal -


in index view have list of models , "create new" button. when user clicks on button modal form should presented 1 field: name of model - field required create model. when user enters name , click submit button model saved , edit view displayed normal page ( fields model available editing).

how achieve this? have tried build new object in index action:

  def index     @my_models = mymodel.all     @new_model = mymodel.build   end 

but did not work (i getting missing template error although without @new_model index displayed without problems)

another question how render form? should put form new.html.erb file , include <%= render 'new' %> in body of modal? (i using bootstrap 3.1 create modal itself)?

you can use

@my_model = mymodel.new 

and call

<%= render 'form' %> 

which uses @my_model.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -