Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. {"utf8"=>"✓",
  2. "_method"=>"put",
  3. "authenticity_token"=>"3193ZMPXkmHdgZThXwAurD6xF2eZ533Tb71pAi7Jxbs=",
  4. "switch_locale"=>"en",
  5. "brand"=>{"title"=>"Cannondale",
  6. "teaser"=>"",
  7. "splash"=>"",
  8. "details"=>"",
  9. "introduction"=>"",
  10. "blockquote"=>"",
  11. "bicycle_type_ids"=>["1",
  12. "2"],
  13. "logo_id"=>"",
  14. "teaser_image_id"=>"",
  15. "splash_image_id"=>""},
  16. "id"=>"2",
  17. "locale"=>:en}
  18.  
  19. module Refinery
  20. module Brands
  21. module Admin
  22. class BrandsController < ::Refinery::AdminController
  23.  
  24. crudify :'refinery/brands/brand',
  25. :xhr_paging => true
  26.  
  27. end
  28. end
  29. end
  30. end
  31.  
  32. module Refinery
  33. module Brands
  34. class Brand < Refinery::Core::BaseModel
  35. self.table_name = 'refinery_brands'
  36.  
  37. attr_accessible :title, :teaser, :splash, :details, :introduction, :blockquote, :logo_id, :teaser_image_id, :splash_image_id, :position, :bicycle_type_ids
  38.  
  39. translates :title, :teaser, :splash, :details, :introduction, :blockquote
  40.  
  41. class Translation
  42. attr_accessible :locale
  43. end
  44.  
  45. validates :title, :presence => true, :uniqueness => true
  46.  
  47. belongs_to :logo, :class_name => '::Refinery::Image'
  48.  
  49. belongs_to :teaser_image, :class_name => '::Refinery::Image'
  50.  
  51. belongs_to :splash_image, :class_name => '::Refinery::Image'
  52.  
  53. has_and_belongs_to_many :bicycle_types
  54. end
  55. end
  56. end
  57.  
  58. module Refinery
  59. module BicycleTypes
  60. class BicycleType < Refinery::Core::BaseModel
  61. self.table_name = 'refinery_bicycle_types'
  62.  
  63. attr_accessible :title, :position
  64.  
  65. translates :title
  66.  
  67. class Translation
  68. attr_accessible :locale
  69. end
  70.  
  71. validates :title, :presence => true, :uniqueness => true
  72.  
  73. has_and_belongs_to_many :brands
  74. accepts_nested_attributes_for :brands
  75. end
  76. end
  77. end
  78.  
  79. class AddRefineryBicycleTypesBrands < ActiveRecord::Migration
  80. def change
  81. create_table :bicycle_types_brands, :id => false do |t|
  82. t.references :bicycle_type
  83. t.references :brand
  84. end
  85. add_index :bicycle_types_brands, [:bicycle_type_id, :brand_id], :unique => true
  86. end
  87. end
  88.  
  89. <div class="field">
  90. <%= f.label :bicycle_types %>
  91. <% Refinery::BicycleTypes::BicycleType.order(:title).each do |bicycle_type| %>
  92. <label class="checkbox">
  93. <%= check_box_tag "#{f.object_name}[bicycle_type_ids][]", bicycle_type.id, f.object.bicycle_types %>
  94. <%= bicycle_type.title %>
  95. </label>
  96. <% end %>
  97. </div>
  98.  
  99. has_and_belongs_to_many :bicycle_types, :class_name => "Refinery::BicycleTypes::BicycleType"
  100.  
  101. has_and_belongs_to_many :bicycle_types, :join_table => :refinery_bicycle_types_brands, :class_name => "Refinery::BicycleTypes::BicycleType"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement