Hi,
I want to be able to determine the gender of a person by clicking on a
picture (a boy and a girl''s face), and it doesn''t work. I can
see the
F or G appear on the screen (when I don''t want that actually because
it is supposed to be hidden...) but it doesn''t save in the record.
Here is my "new.html.erb" view :
<h1>New member</h1>
<% form_for(@member) do |f| %>
<%= f.error_messages %>
<p>
<%= link_to_function(image_tag("Young M.jpg"), nil, :id =>
"M") do |
page|
page.replace_html ''recipient_gender'', "M"
end %>
<%= link_to_function(image_tag("Young F.jpg"), nil, :id =>
"F") do |
page|
page.replace_html ''recipient_gender'', "F"
end %>
</p>
<p>
<div id=''recipient_gender''><% f.hidden_field :gender
%></div>
</p>
<p>
Nickname: <%= f.text_field :nickname %>
</p>
<p>
<%= f.submit "Create member" %>
</p>
<% end %>
And here are my members_controller corresponding actions :
def new
@member = current_user.members.build(params[:member])
end
def create
@member = current_user.members.build(params[:member])
if @member.save
flash[:notice] = ''member is created.''
redirect_to :action => ''index''
else
format.html { render :action => "new" }
format.xml { render :xml => @recipient.errors, :status
=> :unprocessable_entity }
end
end
Thank you
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 24 Mar 2009, at 13:48, Sacredceltic wrote:> end %> > </p> > <p> > <div id=''recipient_gender''><% f.hidden_field :gender %></div> >Your hidden field isn''t actually inserted into the page at all (because you''re using <% instead of <%= ) Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
It won''t work anyway.
In your really clean js code, you''re replacing the content of
"recipient_gender" by text ("f" or "m").
So, you''re replacing <input type="hidden" ...> by
"f" or "m" and it
won''t be submitted to server.
Use labels
On 24 mar, 14:48, Sacredceltic
<sacredcel...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
>
> I want to be able to determine the gender of a person by clicking on a
> picture (a boy and a girl''s face), and it doesn''t work. I
can see the
> F or G appear on the screen (when I don''t want that actually
because
> it is supposed to be hidden...) but it doesn''t save in the record.
>
> Here is my "new.html.erb" view :
>
> <h1>New member</h1>
>
> <% form_for(@member) do |f| %>
> <%= f.error_messages %>
>
> <p>
> <%= link_to_function(image_tag("Young M.jpg"), nil,
:id => "M") do |
> page|
> page.replace_html ''recipient_gender'',
"M"
> end %>
>
> <%= link_to_function(image_tag("Young F.jpg"), nil,
:id => "F") do |
> page|
> page.replace_html ''recipient_gender'',
"F"
> end %>
> </p>
> <p>
> <div id=''recipient_gender''><%
f.hidden_field :gender %></div>
> </p>
> <p>
> Nickname: <%= f.text_field :nickname %>
> </p>
> <p>
> <%= f.submit "Create member" %>
> </p>
> <% end %>
>
> And here are my members_controller corresponding actions :
>
> def new
> @member = current_user.members.build(params[:member])
> end
>
> def create
> @member = current_user.members.build(params[:member])
> if @member.save
> flash[:notice] = ''member is created.''
> redirect_to :action => ''index''
> else
> format.html { render :action => "new" }
> format.xml { render :xml => @recipient.errors, :status
> => :unprocessable_entity }
> end
> end
>
> Thank you
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Very well spotted ! I corrected that but it still doesn''t work... On Mar 24, 2:51 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 24 Mar 2009, at 13:48, Sacredceltic wrote:> end %> > > </p> > > <p> > > <div id=''recipient_gender''><% f.hidden_field :gender %></div> > > Your hidden field isn''t actually inserted into the page at all > (because you''re using <% instead of <%= ) > > Fred--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Could you please explain how to do that ? On Mar 24, 3:00 pm, Florian Dutey <fdu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> It won''t work anyway. > In your really clean js code, you''re replacing the content of > "recipient_gender" by text ("f" or "m"). > So, you''re replacing <input type="hidden" ...> by "f" or "m" and it > won''t be submitted to server. > > Use labels > > On 24 mar, 14:48, Sacredceltic <sacredcel...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > I want to be able to determine the gender of a person by clicking on a > > picture (a boy and a girl''s face), and it doesn''t work. I can see the > > F or G appear on the screen (when I don''t want that actually because > > it is supposed to be hidden...) but it doesn''t save in the record. > > > Here is my "new.html.erb" view : > > > <h1>New member</h1> > > > <% form_for(@member) do |f| %> > > <%= f.error_messages %> > > > <p> > > <%= link_to_function(image_tag("Young M.jpg"), nil, :id => "M") do | > > page| > > page.replace_html ''recipient_gender'', "M" > > end %> > > > <%= link_to_function(image_tag("Young F.jpg"), nil, :id => "F") do | > > page| > > page.replace_html ''recipient_gender'', "F" > > end %> > > </p> > > <p> > > <div id=''recipient_gender''><% f.hidden_field :gender %></div> > > </p> > > <p> > > Nickname: <%= f.text_field :nickname %> > > </p> > > <p> > > <%= f.submit "Create member" %> > > </p> > > <% end %> > > > And here are my members_controller corresponding actions : > > > def new > > @member = current_user.members.build(params[:member]) > > end > > > def create > > @member = current_user.members.build(params[:member]) > > if @member.save > > flash[:notice] = ''member is created.'' > > redirect_to :action => ''index'' > > else > > format.html { render :action => "new" } > > format.xml { render :xml => @recipient.errors, :status > > => :unprocessable_entity } > > end > > end > > > Thank you--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
any hint ? Thank you On Mar 24, 3:57 pm, Sacredceltic <sacredcel...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Could you please explain how to do that ? > > On Mar 24, 3:00 pm, Florian Dutey <fdu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > It won''t work anyway. > > In your really clean js code, you''re replacing the content of > > "recipient_gender" by text ("f" or "m"). > > So, you''re replacing <input type="hidden" ...> by "f" or "m" and it > > won''t be submitted to server. > > > Use labels > > > On 24 mar, 14:48, Sacredceltic <sacredcel...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi, > > > > I want to be able to determine the gender of a person by clicking on a > > > picture (a boy and a girl''s face), and it doesn''t work. I can see the > > > F or G appear on the screen (when I don''t want that actually because > > > it is supposed to be hidden...) but it doesn''t save in the record. > > > > Here is my "new.html.erb" view : > > > > <h1>New member</h1> > > > > <% form_for(@member) do |f| %> > > > <%= f.error_messages %> > > > > <p> > > > <%= link_to_function(image_tag("Young M.jpg"), nil, :id => "M") do | > > > page| > > > page.replace_html ''recipient_gender'', "M" > > > end %> > > > > <%= link_to_function(image_tag("Young F.jpg"), nil, :id => "F") do | > > > page| > > > page.replace_html ''recipient_gender'', "F" > > > end %> > > > </p> > > > <p> > > > <div id=''recipient_gender''><% f.hidden_field :gender %></div> > > > </p> > > > <p> > > > Nickname: <%= f.text_field :nickname %> > > > </p> > > > <p> > > > <%= f.submit "Create member" %> > > > </p> > > > <% end %> > > > > And here are my members_controller corresponding actions : > > > > def new > > > @member = current_user.members.build(params[:member]) > > > end > > > > def create > > > @member = current_user.members.build(params[:member]) > > > if @member.save > > > flash[:notice] = ''member is created.'' > > > redirect_to :action => ''index'' > > > else > > > format.html { render :action => "new" } > > > format.xml { render :xml => @recipient.errors, :status > > > => :unprocessable_entity } > > > end > > > end > > > > Thank you--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I tried this : in my controller : @male = "M" @female="F" in my view : page.replace_html ''recipient_gender'', @male It doesn''t work either... On Mar 25, 8:27 am, Sacredceltic <sacredcel...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> any hint ? > > Thank you > > On Mar 24, 3:57 pm, Sacredceltic <sacredcel...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Could you please explain how to do that ? > > > On Mar 24, 3:00 pm, Florian Dutey <fdu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > It won''t work anyway. > > > In your really clean js code, you''re replacing the content of > > > "recipient_gender" by text ("f" or "m"). > > > So, you''re replacing <input type="hidden" ...> by "f" or "m" and it > > > won''t be submitted to server. > > > > Use labels > > > > On 24 mar, 14:48, Sacredceltic <sacredcel...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi, > > > > > I want to be able to determine the gender of a person by clicking on a > > > > picture (a boy and a girl''s face), and it doesn''t work. I can see the > > > > F or G appear on the screen (when I don''t want that actually because > > > > it is supposed to be hidden...) but it doesn''t save in the record. > > > > > Here is my "new.html.erb" view : > > > > > <h1>New member</h1> > > > > > <% form_for(@member) do |f| %> > > > > <%= f.error_messages %> > > > > > <p> > > > > <%= link_to_function(image_tag("Young M.jpg"), nil, :id => "M") do | > > > > page| > > > > page.replace_html ''recipient_gender'', "M" > > > > end %> > > > > > <%= link_to_function(image_tag("Young F.jpg"), nil, :id => "F") do | > > > > page| > > > > page.replace_html ''recipient_gender'', "F" > > > > end %> > > > > </p> > > > > <p> > > > > <div id=''recipient_gender''><% f.hidden_field :gender %></div> > > > > </p> > > > > <p> > > > > Nickname: <%= f.text_field :nickname %> > > > > </p> > > > > <p> > > > > <%= f.submit "Create member" %> > > > > </p> > > > > <% end %> > > > > > And here are my members_controller corresponding actions : > > > > > def new > > > > @member = current_user.members.build(params[:member]) > > > > end > > > > > def create > > > > @member = current_user.members.build(params[:member]) > > > > if @member.save > > > > flash[:notice] = ''member is created.'' > > > > redirect_to :action => ''index'' > > > > else > > > > format.html { render :action => "new" } > > > > format.xml { render :xml => @recipient.errors, :status > > > > => :unprocessable_entity } > > > > end > > > > end > > > > > Thank you--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---