Hi,
When I submit my form, the value *form_id* is empty, even though I could
see it had a value when I inspected the HTML.
Any clue why it´s stripped? form_id is a virtual attribute on Feature
I´m running Rails 4
1 class Feature < ActiveRecord::Base2 belongs_to :request3
validates_presence_of :title4 validates_presence_of :text5
validates_presence_of :request_id6 7 attr_accessor :form_id8 end
*form.html.slim*
6 = simple_form_for([@request, @feature], remote: remote, 7 html: {class:
"form-inline new_feature feature#{n+1}" }) do |f| 8
.border.padding10 9 = f.error_notification10 11 .form-inputs12 =
f.hidden_field :request_id, :values => @request.id rescue nil13 =
f.hidden_field :form_id, :values => @request.id rescue nil
*From console*:
Processing by FeaturesController#create as JS
Parameters: {"utf8"=>"✓",
"feature"=>{"request_id"=>"",
"*form_id*"=>"",
"title"=>"sdf", "text"=>"sf"},
"commit"=>"Create Feature",
"request_id"=>"43"}
Rendered features/create.js.slim (0.1ms)
Completed 200 OK in 21ms (Views: 3.6ms | ActiveRecord: 4.2ms)
127.0.0.1 - - [03/Sep/2013 10:57:09] "POST /requests/43/features
HTTP/1.1"
200 - 0.0560
*FeaturesController*
1 class FeaturesController < ApplicationController
29 def create30 @request = Request.find(params[:request_id])31
@feature = Feature.new(feature_params)32 @feature.request = @request33 34
respond_to do |format|35 if @feature.save36 format.html {
redirect_to @feature, notice: ''Feature was successfully
created.'' }37 #format.json { render action:
''show'', status: :created, location: @feature }38
format.js39 else40 format.html { render action:
''new'' }41 format.json { render json: @feature.errors,
status: :unprocessable_entity }42 end43 end44 end
78 def feature_params79 params.require(:feature).permit(:request_id,
:text, :title, :form_id)80 end
Cheers,
Martins
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/0cacabe2-29e8-4e33-913c-ca751554d3ed%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.