carrierwave - How to Create One Form Only in Rails to Submit two things Simple Form Carrier Wave -
i building rails platform reddit style type of community international students in boston area. still testing reception of idea. using simple form , carrierwave. got @student = student.new
instance in signup method. got @uploader = student.new.picture
in signup method (using carrierwave). idea every student has picture associated him or her. got carrierwave's picture feature mounted on student model. using carrierwave_direct gem directly upload pictures s3 storage on amazon.
my signup.html.erb looks
<div class = "signupform"> <%= simple_form_for @student, :html => {:multipart => true} |f| %> <%= f.input :last_name, label: '姓'%> <%= f.input :first_name, label: '名' %> <%= f.input :email, label: '电子邮件' %> <%= f.input :password, label: '密码' %> <%= f.input :college, label: '大学' %> <%= f.input :budget, label: '房间租金预算 (optional)' %> <%= f.button :submit %> <br> picture optional <% end %> <%= direct_upload_form_for @uploader |f| %> <p><%= f.file_field :picture %></p> <%= f.button :submit %> <% end %> </div>
how make 1 form? have 2 submit buttons on form, user can create account redirected thank page or user can upload picture , not create account?
the direct_upload_form_for directly helper view method carrier direct needed upload directly s3 suppose ?
why using 2 forms instead of 1 form? include image upload in student model.
<%= simple_form_for @student, :html => {:multipart => true} |f| %> <%= f.input :last_name, label: '姓'%> <%= f.input :first_name, label: '名' %> <%= f.input :email, label: '电子邮件' %> <%= f.input :password, label: '密码' %> <%= f.input :college, label: '大学' %> <%= f.input :budget, label: '房间租金预算 (optional)' %> <%= f.file_field :picture, label: 'student photo (optional)' %> <%= f.button :submit %> <br>
can call helper method simple_form? if need form way about
<%= simple_form_for @student, :html => {:multipart => true} |f| %> <%= f.input :last_name, label: '姓'%> <%= f.input :first_name, label: '名' %> <%= f.input :email, label: '电子邮件' %> <%= f.input :password, label: '密码' %> <%= f.input :college, label: '大学' %> <%= f.input :budget, label: '房间租金预算 (optional)' %> <%= direct_upload_form_for @uploader |f| %> <p><%= f.file_field :picture %></p> <%= f.button :submit %> <br>
Comments
Post a Comment