Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 197

Show
Ignore:
Timestamp:
12/16/04 19:43:27 (4 years ago)
Author:
david
Message:

Made the last tweaks before 0.9

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml

    r4 r197  
    2020    a:visited { color: #666; } 
    2121    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    } 
    2258  </style> 
    2359</head> 
  • trunk/activerecord/lib/active_record/acts/list.rb

    r191 r197  
    4949             
    5050            before_destroy :remove_from_list 
    51             after_create   :add_to_list_bottom 
     51            before_create   :add_to_list_bottom 
    5252          EOV 
    5353        end 
     
    8989   
    9090 
    91         def add_to_list_top 
    92           increment_positions_on_all_items 
    93         end 
    94  
    95         def add_to_list_bottom 
    96           assume_bottom_position 
    97         end 
    98  
    9991        def remove_from_list 
    10092          decrement_positions_on_lower_items 
     
    120112 
    121113        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 
    124153   
    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 
    130157   
    131           def lower_item 
    132             self.class.find_first
    133               "#{scope_condition} AND #{position_column} = #{(send(position_column).to_i + 1).to_s}" 
    134            
    135           end 
     158        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 
    136163   
    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 
    148169 
    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 
    174175      end      
    175176    end 
  • trunk/activerecord/lib/active_record/validations.rb

    r193 r197  
    191191          end 
    192192        end         
    193          
    194193      end 
    195194 
     
    402401    def add_on_boundary_breaking(attributes, range, too_long_msg = @@default_error_messages[:too_long], too_short_msg = @@default_error_messages[:too_short]) 
    403402      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.begin 
    405         add(attr, too_long_msg % range.end) if @base.attribute_present?(attr.to_s) && @base.send(attr.to_s).length > range.end 
     403        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 
    406405      end 
    407406    end 
  • trunk/railties/generators/scaffold/templates/controller.rb

    r159 r197  
    11class <%= class_name %>Controller < ApplicationController 
    2   model   :<%= singular_name %> 
    3   layout  'scaffold' 
     2  layout 'scaffold' 
    43 
    54<% unless suffix -%> 
  • trunk/railties/generators/scaffold/templates/functional_test.rb

    r169 r197  
    6363 
    6464  def test_update<%= suffix %> 
    65     process :update<%= suffix %>, 'id' => 1 
     65    process :update<%= suffix %>, '<%= singular_name %>' => { 'id' => 1 } 
    6666    assert_redirected_to :action => 'show<%= suffix %>', :id => 1 
    6767  end 
  • trunk/railties/generators/scaffold/templates/style.css

    r63 r197  
    1616a:visited { color: #666; } 
    1717a: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  
    2525 
    2626class 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) 
    3028    Breakpoint.activate_drb("druby://localhost:#{BREAKPOINT_SERVER_PORT}", nil, !defined?(FastCGI)) if defined?(BREAKPOINT_SERVER_PORT) 
    3129