Changeset 197
- Timestamp:
- 12/16/04 19:43:27 (4 years ago)
- Files:
-
- trunk/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml (modified) (1 diff)
- trunk/activerecord/lib/active_record/acts/list.rb (modified) (3 diffs)
- trunk/activerecord/lib/active_record/validations.rb (modified) (2 diffs)
- trunk/railties/generators/scaffold/templates/controller.rb (modified) (1 diff)
- trunk/railties/generators/scaffold/templates/functional_test.rb (modified) (1 diff)
- trunk/railties/generators/scaffold/templates/style.css (modified) (1 diff)
- trunk/railties/lib/dispatcher.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml
r4 r197 20 20 a:visited { color: #666; } 21 21 a:hover { color: #fff; background-color:#000; } 22 23 .fieldWithErrors { 24 padding: 2px; 25 background-color: red; 26 display: table; 27 } 28 29 #ErrorExplanation { 30 width: 400px; 31 border: 2px solid #red; 32 padding: 7px; 33 padding-bottom: 12px; 34 margin-bottom: 20px; 35 background-color: #f0f0f0; 36 } 37 38 #ErrorExplanation h2 { 39 text-align: left; 40 font-weight: bold; 41 padding: 5px 5px 5px 15px; 42 font-size: 12px; 43 margin: -7px; 44 background-color: #c00; 45 color: #fff; 46 } 47 48 #ErrorExplanation p { 49 color: #333; 50 margin-bottom: 0; 51 padding: 5px; 52 } 53 54 #ErrorExplanation ul li { 55 font-size: 12px; 56 list-style: square; 57 } 22 58 </style> 23 59 </head> trunk/activerecord/lib/active_record/acts/list.rb
r191 r197 49 49 50 50 before_destroy :remove_from_list 51 after_create :add_to_list_bottom51 before_create :add_to_list_bottom 52 52 EOV 53 53 end … … 89 89 90 90 91 def add_to_list_top92 increment_positions_on_all_items93 end94 95 def add_to_list_bottom96 assume_bottom_position97 end98 99 91 def remove_from_list 100 92 decrement_positions_on_lower_items … … 120 112 121 113 private 122 # Overwrite this method to define the scope of the list changes 123 def scope_condition() "1" end 114 115 def add_to_list_top 116 increment_positions_on_all_items 117 end 118 119 def add_to_list_bottom 120 write_attribute(position_column, bottom_position_in_list.to_i + 1) 121 end 122 123 # Overwrite this method to define the scope of the list changes 124 def scope_condition() "1" end 125 126 def higher_item 127 self.class.find_first( 128 "#{scope_condition} AND #{position_column} = #{(send(position_column).to_i - 1).to_s}" 129 ) 130 end 131 132 def lower_item 133 self.class.find_first( 134 "#{scope_condition} AND #{position_column} = #{(send(position_column).to_i + 1).to_s}" 135 ) 136 end 137 138 def bottom_position_in_list 139 item = bottom_item 140 item ? item.send(position_column) : 0 141 end 142 143 def bottom_item 144 self.class.find_first( 145 "#{scope_condition} ", 146 "#{position_column} DESC" 147 ) 148 end 149 150 def assume_bottom_position 151 update_attribute position_column, bottom_position_in_list.to_i + 1 152 end 124 153 125 def higher_item 126 self.class.find_first( 127 "#{scope_condition} AND #{position_column} = #{(send(position_column).to_i - 1).to_s}" 128 ) 129 end 154 def assume_top_position 155 update_attribute position_column, 1 156 end 130 157 131 def lower_item132 self.class.find_first(133 "#{scope_condition} AND #{position_column} = #{(send(position_column).to_i + 1).to_s}"134 )135 end158 def decrement_positions_on_lower_items 159 self.class.update_all( 160 "#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} > #{send(position_column).to_i}" 161 ) 162 end 136 163 137 def bottom_position_in_list 138 item = bottom_item 139 item ? item.send(position_column) : 0 140 end 141 142 def bottom_item 143 self.class.find_first( 144 "#{scope_condition} ", 145 "#{position_column} DESC" 146 ) 147 end 164 def increment_positions_on_higher_items 165 self.class.update_all( 166 "#{position_column} = (#{position_column} + 1)", "#{scope_condition} AND #{position_column} < #{send(position_column)}" 167 ) 168 end 148 169 149 def assume_bottom_position 150 update_attribute position_column, bottom_position_in_list.to_i + 1 151 end 152 153 def assume_top_position 154 update_attribute position_column, 1 155 end 156 157 def decrement_positions_on_lower_items 158 self.class.update_all( 159 "#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} > #{send(position_column).to_i}" 160 ) 161 end 162 163 def increment_positions_on_higher_items 164 self.class.update_all( 165 "#{position_column} = (#{position_column} + 1)", "#{scope_condition} AND #{position_column} < #{send(position_column)}" 166 ) 167 end 168 169 def increment_positions_on_all_items 170 self.class.update_all( 171 "#{position_column} = (#{position_column} + 1)", "#{scope_condition}" 172 ) 173 end 170 def increment_positions_on_all_items 171 self.class.update_all( 172 "#{position_column} = (#{position_column} + 1)", "#{scope_condition}" 173 ) 174 end 174 175 end 175 176 end trunk/activerecord/lib/active_record/validations.rb
r193 r197 191 191 end 192 192 end 193 194 193 end 195 194 … … 402 401 def add_on_boundary_breaking(attributes, range, too_long_msg = @@default_error_messages[:too_long], too_short_msg = @@default_error_messages[:too_short]) 403 402 for attr in [attributes].flatten 404 add(attr, too_short_msg % range.begin) if @base .attribute_present?(attr.to_s)&& @base.send(attr.to_s).length < range.begin405 add(attr, too_long_msg % range.end) if @base .attribute_present?(attr.to_s)&& @base.send(attr.to_s).length > range.end403 add(attr, too_short_msg % range.begin) if @base[attr.to_s] && @base.send(attr.to_s).length < range.begin 404 add(attr, too_long_msg % range.end) if @base[attr.to_s] && @base.send(attr.to_s).length > range.end 406 405 end 407 406 end trunk/railties/generators/scaffold/templates/controller.rb
r159 r197 1 1 class <%= class_name %>Controller < ApplicationController 2 model :<%= singular_name %> 3 layout 'scaffold' 2 layout 'scaffold' 4 3 5 4 <% unless suffix -%> trunk/railties/generators/scaffold/templates/functional_test.rb
r169 r197 63 63 64 64 def test_update<%= suffix %> 65 process :update<%= suffix %>, ' id' => 165 process :update<%= suffix %>, '<%= singular_name %>' => { 'id' => 1 } 66 66 assert_redirected_to :action => 'show<%= suffix %>', :id => 1 67 67 end trunk/railties/generators/scaffold/templates/style.css
r63 r197 16 16 a:visited { color: #666; } 17 17 a:hover { color: #fff; background-color:#000; } 18 19 .fieldWithErrors { 20 padding: 2px; 21 background-color: red; 22 display: table; 23 } 24 25 #ErrorExplanation { 26 width: 400px; 27 border: 2px solid #red; 28 padding: 7px; 29 padding-bottom: 12px; 30 margin-bottom: 20px; 31 background-color: #f0f0f0; 32 } 33 34 #ErrorExplanation h2 { 35 text-align: left; 36 font-weight: bold; 37 padding: 5px 5px 5px 15px; 38 font-size: 12px; 39 margin: -7px; 40 background-color: #c00; 41 color: #fff; 42 } 43 44 #ErrorExplanation p { 45 color: #333; 46 margin-bottom: 0; 47 padding: 5px; 48 } 49 50 #ErrorExplanation ul li { 51 font-size: 12px; 52 list-style: square; 53 } trunk/railties/lib/dispatcher.rb
r159 r197 25 25 26 26 class Dispatcher 27 DEFAULT_SESSION_OPTIONS = { :database_manager => CGI::Session::PStore, :prefix => "ruby_sess.", :session_path => "/" } 28 29 def self.dispatch(cgi = CGI.new, session_options = DEFAULT_SESSION_OPTIONS) 27 def self.dispatch(cgi = CGI.new, session_options = ActionController::CgiRequest.DEFAULT_SESSION_OPTIONS) 30 28 Breakpoint.activate_drb("druby://localhost:#{BREAKPOINT_SERVER_PORT}", nil, !defined?(FastCGI)) if defined?(BREAKPOINT_SERVER_PORT) 31 29