Last active
August 28, 2015 00:08
-
-
Save willsza/5017897ee66a33875b32 to your computer and use it in GitHub Desktop.
Select com simple_fields_for
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
.main-home | |
- @goals.each do |goal| | |
h1.text-center = goal.title | |
= simple_form_for goal do |f| | |
= f.error_notification | |
.form-group.text-center | |
= f.simple_fields_for :goal_options do |g| | |
= g.simple_fields_for :user_goal_options do |u| | |
= u.input :goal_option_id do | |
= g.select :goal_option_id | |
.form-group.text-center | |
= f.submit "Avançar", class: 'btn btn-success btn-lg' | |
hr |
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 Goal < ActiveRecord::Base | |
belongs_to :page | |
has_many :goal_options | |
validates :title, presence: true | |
accepts_nested_attributes_for :goal_options | |
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 GoalOption < ActiveRecord::Base | |
belongs_to :goal | |
# Relacionamento muitos pra muitos com User | |
has_many :user_goal_options | |
has_many :users, | |
:through => :user_goal_options | |
accepts_nested_attributes_for :user_goal_options | |
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 User < ActiveRecord::Base | |
has_many :answers | |
# Relacionamento muitos pra muitos com Goal | |
has_many :user_goal_options | |
has_many :goal_optons, | |
:through => :user_goal_options | |
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 UserGoalOption < ActiveRecord::Base | |
belongs_to :user | |
belongs_to :goal_option | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment