Created
December 28, 2011 08:06
-
-
Save Znow/1527054 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= form_for(admin_stocks_path(@stock)) do |f| | |
- if @stock.errors.any? | |
#error_explanation | |
%h2 | |
= pluralize(@stock.errors.count, "error") | |
prohibited this stock from being saved: | |
%ul | |
- @stock.errors.full_messages.each do |msg| | |
%li= msg | |
.field | |
= f.label :value, "Værdi" | |
%br/ | |
= f.number_field :value | |
.field | |
= f.label :month, "Måned" | |
%br/ | |
= f.number_field :month | |
.field | |
= f.label :year, "År" | |
%br/ | |
= f.number_field :year | |
.field | |
= select(:investor, :id, options_from_collection_for_select(Investor.all, :id, :name)) | |
%br/ | |
.actions | |
= f.submit "Gem" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Routing Error | |
No route matches {:action=>"edit", :controller=>"admin/advice_pages"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Started POST "/admin/stocks/new" for 192.168.233.1 at 2011-12-28 09:25:58 +0100 | |
Processing by PagesController#show as HTML | |
Parameters: {"utf8"=>"â", "authenticity_token"=>"XKCFodVxWC7/HzW3mXasGnfMV5F8sRphsX1TtBPABsg=", "/admin/stocks"=>{"value"=>"1000", "month"=>"1", "year"=>"2013"}, "investor"=>{"id"=>"1"}, "commit"=>"Gem", "slugs"=>"admin/stocks/new"} | |
AdvicePage Load (0.2ms) SELECT "advice_pages".* FROM "advice_pages" WHERE "advice_pages"."slug" = '/admin/stocks/new' ORDER BY "advice_pages"."id" DESC LIMIT 1 | |
Rendered pages/show.haml within layouts/application (4.0ms) | |
Rendered layouts/_menu.haml (7.0ms) | |
Rendered layouts/_header.haml (7.9ms) | |
User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1 | |
Rendered layouts/_admin_menu.haml (5.3ms) | |
Rendered layouts/_sub_pages.haml (0.8ms) | |
Rendered layouts/_footer.haml (0.2ms) | |
Completed 200 OK in 194ms (Views: 90.6ms | ActiveRecord: 2.7ms) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%h3 Ny aktie | |
= render 'form' | |
= link_to 'Tilbage', admin_stocks_path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PagesController < ApplicationController | |
def show | |
@page = AdvicePage.where(:slug => request.path).last | |
@path = request.path | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Advicecapital::Application.routes.draw do | |
match '/contact' => 'contact#new', :as => 'contact', :via => :get | |
match '/contact' => 'contact#create', :as => 'contact', :via => :post | |
devise_for :users | |
resources :news | |
resources :boards | |
#resources :contacts, :only => [:new, :create] | |
resources :videos | |
resources :employees | |
namespace :admin do | |
root :to => 'dashboard#index' | |
resources :advice_pages | |
resources :boxes, :only => [:index, :show, :edit, :update] | |
resources :investors | |
resources :stocks | |
resources :users | |
end | |
root :to => "pages#index" | |
match '/receive_news', :to => 'pages#receive_news' | |
match '/disclaimer', :to => 'pages#disclaimer' | |
match '/organisation', :to => 'admin/employees#index' | |
mount Resque::Server, :at => "/resque" | |
match '/*slugs', :to => 'pages#show' | |
# AdvicePage.all.each do |r| | |
# match r.slug, :to => "pages#show" | |
# end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.span-20 | |
%h3 | |
%span#page_title | |
= raw @page.title if @page.title | |
%p | |
#page_content | |
= raw @page.content if @page.content | |
- if can? :manage, @page | |
= link_to "Rediger side", edit_admin_advice_page_path(@page) | |
- if Rails.env.development? | |
= @path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Admin::StocksController < AdminController | |
# GET /stocks | |
# GET /stocks.json | |
def index | |
@stocks = Stock.order("value").page(params[:page]).per(10) | |
respond_to do |format| | |
format.html # index.html.erb | |
format.json { render json: @stocks } | |
end | |
end | |
# GET /stocks/1 | |
# GET /stocks/1.json | |
def show | |
@stock = Stock.find(params[:id]) | |
respond_to do |format| | |
format.html # show.html.erb | |
format.json { render json: @stock } | |
end | |
end | |
# GET /stocks/new | |
# GET /stocks/new.json | |
def new | |
@stock = Stock.new | |
respond_to do |format| | |
format.html # new.html.erb | |
format.json { render json: @stock } | |
end | |
end | |
# GET /stocks/1/edit | |
def edit | |
@stock = Stock.find(params[:id]) | |
end | |
# POST /stocks | |
# POST /stocks.json | |
def create | |
@stock = Stock.new(params[:stock]) | |
respond_to do |format| | |
if @stock.save | |
format.html { redirect_to @stock, notice: 'Stock was successfully created.' } | |
format.json { render json: @stock, status: :created, location: @stock } | |
else | |
format.html { render action: "new" } | |
format.json { render json: @stock.errors, status: :unprocessable_entity } | |
end | |
end | |
end | |
# PUT /stocks/1 | |
# PUT /stocks/1.json | |
def update | |
@stock = Stock.find(params[:id]) | |
respond_to do |format| | |
if @stock.update_attributes(params[:stock]) | |
format.html { redirect_to @stock, notice: 'Stock was successfully updated.' } | |
format.json { head :ok } | |
else | |
format.html { render action: "edit" } | |
format.json { render json: @stock.errors, status: :unprocessable_entity } | |
end | |
end | |
end | |
# DELETE /stocks/1 | |
# DELETE /stocks/1.json | |
def destroy | |
@stock = Stock.find(params[:id]) | |
@stock.destroy | |
respond_to do |format| | |
format.html { redirect_to stocks_url } | |
format.json { head :ok } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment