ruby on rails - Multiple form for the same model -


i have 2 models named station , stream. station has_many streams. have form streams @ streams/new page , on submission sets station_id current_user.station_id (i have model user has_many stations). need allow user click button "add more streams" on form, duplicate existing streams form , show 1 submit button. when user submits form, creates multiple entries in streams table station_id set @ current_user.station_id. user never create station. created admin , allocated particular users. how achieve this?

you need use accepts_nested_attributes_for method in model. can find great example of how here: http://railscasts.com/episodes/196-nested-model-form-revised?view=similar

you can using cocoon gem: https://github.com/nathanvda/cocoon


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -