SHIMADA Koji
null+****@clear*****
Tue Sep 25 20:21:22 JST 2012
SHIMADA Koji 2012-09-25 20:21:22 +0900 (Tue, 25 Sep 2012) New Revision: 2e02e217064faf892914f64c4cbcfe6fcf445556 https://github.com/logaling/logaling-server/commit/2e02e217064faf892914f64c4cbcfe6fcf445556 Merged 971b851: Merge pull request #14 from logaling/prioritize-the-search Log: Move decoration for UserConfig to UserConfigDecorator Added files: app/decorators/user_config_decorator.rb Modified files: app/views/dashboard/show.html.haml Added: app/decorators/user_config_decorator.rb (+14 -0) 100644 =================================================================== --- /dev/null +++ app/decorators/user_config_decorator.rb 2012-09-25 20:21:22 +0900 (5e2d0d5) @@ -0,0 +1,14 @@ +# coding: utf-8 +module UserConfigDecorator + def mark_for(user_glossary) + self.same?(user_glossary) ? "★" : "☆" + end + + def submit_path_for(user) + if self.new_record? + user_configs_path(user) + else + user_config_path(user, self) + end + end +end Modified: app/views/dashboard/show.html.haml (+2 -4) =================================================================== --- app/views/dashboard/show.html.haml 2012-09-25 20:20:23 +0900 (e0ce876) +++ app/views/dashboard/show.html.haml 2012-09-25 20:21:22 +0900 (67fef35) @@ -5,14 +5,12 @@ %ul - @user_glossaries.each do |user_glossary| %li - - mark = @user_config.same?(user_glossary) ? "★" : "☆" = user_glossary.glossary_name = user_glossary.source_language = user_glossary.target_language = link_to "Show", user_glossary_path(current_user, user_glossary) - - config_submit_path = @user_config.new_record? ? user_configs_path(current_user) : user_config_path(current_user, @user_config) - = form_for @user_config, url: config_submit_path do |f| + = form_for @user_config, url: @user_config.submit_path_for(current_user) do |f| = f.hidden_field :glossary_name, value: user_glossary.glossary_name = f.hidden_field :source_language, value: user_glossary.source_language = f.hidden_field :target_language, value: user_glossary.target_language - = f.submit mark, :class => 'btn btn-link' + = f.submit @user_config.mark_for(user_glossary), :class => 'btn btn-link' -------------- next part -------------- An HTML attachment was scrubbed... Télécharger