Class: EngineRoom::FieldsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- EngineRoom::FieldsController
- Defined in:
- app/controllers/engine_room/fields_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /fields.
-
#destroy ⇒ Object
DELETE /fields/1.
-
#edit ⇒ Object
GET /fields/1/edit.
-
#index ⇒ Object
GET /sections.
- #init_sections ⇒ Object
-
#new ⇒ Object
GET /fields/new.
-
#show ⇒ Object
GET /fields/1.
-
#update ⇒ Object
PUT /fields/1.
Instance Method Details
#create ⇒ Object
POST /fields
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/engine_room/fields_controller.rb', line 47 def create @field = Field.new(params[:field]) @section = Section.find(params[:section_id]) if(params[:s_action]=='reload') return reload_new end if @field.save flash[:notice] = 'Field was successfully created.' redirect_to edit_engine_room_section_url(@section.id) else render :action => :new end end |
#destroy ⇒ Object
DELETE /fields/1
83 84 85 86 87 88 89 90 91 |
# File 'app/controllers/engine_room/fields_controller.rb', line 83 def destroy @field = Field.find(params[:id]) @field.destroy flash[:notice] = 'Field was successfully deleted.' section_id = params[:section_id] redirect_to edit_engine_room_section_url(section_id) end |
#edit ⇒ Object
GET /fields/1/edit
38 39 40 41 42 43 44 |
# File 'app/controllers/engine_room/fields_controller.rb', line 38 def edit @field = Field.find(params[:id]) @section = Section.find(params[:section_id]) add_crumb(@section.name.titleize, edit_engine_room_section_path(@section.id)) add_crumb('Edit Field', edit_engine_room_section_field_path(@section, @field.id)) end |
#index ⇒ Object
GET /sections
17 18 19 20 |
# File 'app/controllers/engine_room/fields_controller.rb', line 17 def index @fields = Field.all # index.html.erb end |
#init_sections ⇒ Object
10 11 12 13 14 |
# File 'app/controllers/engine_room/fields_controller.rb', line 10 def init_sections @sections = Section.all @layout = 'columns' @sidebar = 'engine_room/sections' end |
#new ⇒ Object
GET /fields/new
29 30 31 32 33 34 35 |
# File 'app/controllers/engine_room/fields_controller.rb', line 29 def new @field = Field.new @section = Section.find(params[:section_id]) add_crumb(@section.name.titleize, edit_engine_room_section_path(@section.id)) add_crumb 'New Field' end |
#show ⇒ Object
GET /fields/1
23 24 25 26 |
# File 'app/controllers/engine_room/fields_controller.rb', line 23 def show @field = Field.find(params[:id]) # show.html.erb end |
#update ⇒ Object
PUT /fields/1
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/controllers/engine_room/fields_controller.rb', line 64 def update @field = Field.find(params[:id]) @section = Section.find(params[:section_id]) if(params[:s_action]=='reload') return reload_edit end @field. = nil # remove all old options if @field.update_attributes(params[:field]) flash[:notice] = 'Field was successfully updated.' redirect_to edit_engine_room_section_url(@section.id) else #render :action => :edit reload_edit end end |