Class: Bhf::EntriesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Bhf::EntriesController
- Defined in:
- app/controllers/bhf/entries_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/bhf/entries_controller.rb', line 18 def create @object = @model.new(params[@model_sym]) after_load before_save if @object.save manage_many_to_many after_save redirect_back_or_default(bhf_entry_path(@platform.name, @object), :notice => ('create.success', @model)) else @form_url = bhf_entries_path(@platform.name) render :new end end |
#destroy ⇒ Object
68 69 70 71 |
# File 'app/controllers/bhf/entries_controller.rb', line 68 def destroy @object.destroy redirect_back_or_default(bhf_page_path(@platform.page_name, :anchor => "#{@platform.name}_platform"), :notice => ('destory.success', @model)) end |
#edit ⇒ Object
12 13 14 15 16 |
# File 'app/controllers/bhf/entries_controller.rb', line 12 def edit @form_url = bhf_entry_path(@platform.name, @object) render :layout => 'bhf/quick_edit' if @quick_edit end |
#new ⇒ Object
5 6 7 8 9 10 |
# File 'app/controllers/bhf/entries_controller.rb', line 5 def new @object = @model.new after_load @form_url = bhf_entries_path(@platform.name) end |
#sort ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/bhf/entries_controller.rb', line 54 def sort return unless @platform.sortable sort_attr = @platform.sortable.to_sym params[:order].each do |order| @model. find(order[1].gsub("_#{@platform.name}", '')). update_attribute(sort_attr, order[0].to_i) end head :ok end |
#update ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/bhf/entries_controller.rb', line 34 def update before_save if @object.update_attributes(params[@model_sym]) manage_many_to_many after_save if @quick_edit render :json => object_to_bhf_display_hash, :status => :ok else redirect_back_or_default(bhf_entry_path(@platform.name, @object), :notice => ('update.success', @model)) end else @form_url = bhf_entry_path(@platform.name, @object) r_settings = {:status => :unprocessable_entity} r_settings[:layout] = 'bhf/quick_edit' if @quick_edit render :edit, r_settings end end |