Jump to content

The ultimate community for Ruby on Rails developers.


inserting has_many through record metadata during devise registration

  • Please log in to reply
No replies to this topic

#1 jangoon



  • Members
  • 1 posts

Posted 14 November 2013 - 11:35 AM

I would like to thank you in advance. I have been looking around of the internet to get an answer for this but could not find anything so here goes the questions.

I have a user registration process through devise that I have customized the registration looks like so.

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>

<div><%= f.label :name %><br />
<%= f.email_field :name, :autofocus => true %></div>

<div><%= f.label :email %><br />
<%= f.email_field :email, :autofocus => true %></div>

<div><%= f.label :password %><br />
<%= f.password_field :password %></div>

<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>

<div>Teaching:<%= f.label :language_ids %><br />
<%= collection_select('user', 'language_ids', @languages, :id, :name, {}, {:included_blank => false,:multiple => true } ) %>

<div>Learning:<%= f.label :language_ids %><br />
<%= collection_select('user', 'language_ids', @languages, :id, :name, {}, {:included_blank => false,:multiple => true } ) %>
On my controller currently it looks like this
def create
@languages = Language.all

if resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?
sign_up(resource_name, resource)
respond_with resource, :location => after_sign_up_path_for(resource)
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
respond_with resource, :location => after_inactive_sign_up_path_for(resource)
clean_up_passwords resource
respond_with resource

Now there is a field that i have to set to toggle the metadata flag on the intermediary table/model called fluency. Basically I need to set it to 0 if the data is coming from the Learning multiselect and a 1 if the data comes from the Teaching multiselect. Currently it's just inserting it without toggling that metadata.

Been looking all over but can't find anything.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users