Class: Birdses::PagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Birdses::PagesController
- Defined in:
- app/controllers/birdses/pages_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 |
# File 'app/controllers/birdses/pages_controller.rb', line 16 def create name = params[:page][:name].gsub(/\//, '-') content = params[:page][:raw_data] @page = Page.create(name, content, @user) redirect_to "#{pages_path}/#{name}" end |
#destroy ⇒ Object
30 31 32 33 |
# File 'app/controllers/birdses/pages_controller.rb', line 30 def destroy Page.destroy(params[:id], @user) redirect_to pages_path end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/birdses/pages_controller.rb', line 8 def index @pages = Page.all end |
#new ⇒ Object
12 13 14 |
# File 'app/controllers/birdses/pages_controller.rb', line 12 def new @page = Page.new end |
#preview ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'app/controllers/birdses/pages_controller.rb', line 35 def preview md = Page.preview(params[:name], params[:md_content]) html = md.formatted_data respond_to do |format| format.json { render :json => { :html => html } } end end |
#update ⇒ Object
23 24 25 26 27 28 |
# File 'app/controllers/birdses/pages_controller.rb', line 23 def update name = params[:id] content = params[:page][:raw_data] Page.update(name, content, @user) redirect_to "#{pages_path}/#{name}" end |