This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Answer < ActiveRecord::Base | |
belongs_to :question | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Questionnaire < ActiveRecord::Base | |
has_many :questionnaire_surveys | |
has_many :surveys, through: :questionnaire_surveys | |
accepts_nested_attributes_for :questionnaire_surveys | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. MODEL | |
item has many item_childrens | |
-> user has one answersheet | |
2. CONTROLLER | |
item_controller -> user_controller | |
multi method -> useranswer method | |
3. CONTROLLER | |
def useranswer method end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class='content_wrapper option_wrapper'> | |
<ul class = 'option_first_banner clearfix'> | |
<li class = 'option_right_banner'> | |
<%= form_for @profile, :url => dashboard_user_profiles_path, :method => :POST do |f| %> | |
<div class="edit_panel panel panel-default"> | |
<div class="edit_heading panel-heading"> | |
<h3 class="panel-title">個人資料</h3> | |
</div> | |
<div class="panel-body"> | |
<div class='option_content'> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_tag multi_save_item_path do %> | |
<% age_list = (18..30).to_a %> | |
<ol> | |
<li class="template"> | |
name<input data-name="ic[name][]"> , | |
age<select data-name="ic[age][]"><%= options_for_select(age_list) %></select> | |
<span class="add">add</span><span class="del">del</span></li> | |
<% @item_childs.each do |old_ic| %> | |
<li class="old_record"> | |
name<%= text_field_tag "ic_old[#{old_ic.id}][name]" , old_ic.name %> , |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update | |
@profile = @user.profile | |
ids = @profile.profile_option.map{|t| t.option_id} | |
if ids.length > 0 | |
ProfileOption.where("profile_id =? AND option_id NOT IN (#{ids.join(',')})", @profile.id).delete_all | |
else | |
ProfileOption.where("profile_id = ?", @profile.id).delete_all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Option < ActiveRecord::Base | |
belongs_to :issue | |
has_many :respond, :dependent => :destroy | |
has_many :user, through: :respond | |
#可以用的 | |
has_many :profile_option | |
has_many :profile, through: :profile_option | |
#可以用的 | |
end |