Created
March 15, 2012 00:36
-
-
Save anonymous/2040730 to your computer and use it in GitHub Desktop.
no route matches error
This file contains 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
1 class ProjectsController < ApplicationController | |
2 | |
3 def index | |
4 @projects = Project.all | |
5 end | |
6 | |
7 def new | |
8 @project = Project.new | |
9 end | |
10 | |
11 def create | |
12 @project = Project.new(params[:project]) | |
13 | |
14 if @project.save | |
15 redirect_to (projects_path) | |
16 else | |
17 redirect_to(new_project_path) | |
18 end | |
19 end | |
20 | |
21 def show | |
22 @project = Project.find(params[:id]) | |
23 end | |
24 | |
25 def edit | |
26 @project = Project.find(params[:id]) | |
27 end | |
28 | |
29 def update | |
30 @project = Project.find(params[:id]) | |
31 if @project.update_attributes(params[:project]) | |
32 redirect_to (project_path) | |
33 else | |
34 redirect_to (edit_project_path) | |
35 end | |
36 end | |
37 | |
38 def delete | |
39 @project = Project.find(params[:id]) | |
40 render 'delete' | |
41 end | |
42 | |
43 def destroy | |
44 project = Project.find(params[:id]) | |
45 project.destroy | |
46 flash[:notice] = "Page succesfully removed" | |
47 redirect_to(projects_path) | |
48 end | |
49 | |
50 #private | |
51 #def project | |
52 # @project ||= Project.find(params[:id]) | |
53 #end | |
54 | |
55 end | |
This file contains 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
1 SimpleCms::Application.routes.draw do. | |
2 | |
3 resources :projects | |
4 resources :users | |
5 | |
6 end |
This file contains 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
1 <%= form_for(:project, :url => {:action => 'destroy', :id => @project.id }) do |f| %> | |
2 <p>Are you sure you want to remove "<%= @project.name %>"</p> | |
3 <%= submit_tag ("Yes, I am sure") | |
4 <% end %> |
This file contains 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
1 <h2>Edit Project</h2> | |
2 | |
3 <%= form_for @project do |f| %> | |
4 | |
5 <%= f.label "Project name" %><br/> | |
6 <%= f.text_field :name %><br/> | |
7 <%= f.label "Project description" %><br/> | |
8 <%= f.text_area :description, :cols => 40, :rows => 4 %><br/> | |
9 | |
10 <br/> | |
11 <%= submit_tag ("Update project") %> | |
12 | |
13 <% end %> |
This file contains 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
1 <%= link_to 'Create new project', new_project_path %> | |
2 | |
3 <h1>Projects</h1> | |
4 | |
5 <% @projects.each do |p| %> | |
6 <h2> | |
7 <%= link_to p.name, project_path(p) %> | |
8 <%= link_to "edit", edit_project_path(p) %> | |
9 <%= link_to "delete",{ :action => 'delete', :controller => 'projects', :id => p.id } %> | |
10 </h2> | |
11 <%= p.description %><br/> | |
12 | |
13 <% p.users.each do |u| %> | |
14 <%= u.user_name %> | |
15 <br/> | |
16 <% end %> | |
17 | |
18 <br/> | |
19 | |
20 <% end %> | |
This file contains 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
1 <h2>Create new Project</h2> | |
2 | |
3 <%= form_for @project do |f| %> | |
4 | |
5 <%= f.label "Project name" %><br/> | |
6 <%= f.text_field :name %><br/> | |
7 <%= f.label "Project description" %><br/> | |
8 <%= f.text_area :description, :cols => 40, :rows => 4 %><br/> | |
9 | |
10 <br/> | |
11 <%= submit_tag ("Create Project") %> | |
12 | |
13 <% end %> |
This file contains 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
1 <%= link_to "Projects", projects_path %> | |
2 | |
3 <h1><%= @project.name %></h2> | |
4 | |
5 <%= @project.description %><br/> | |
6 <% @project.users.each do |u| %> | |
7 <%= u.user_name %> | |
8 <br/> | |
9 <% end %> | |
10 | |
11 <br/> | |
12 | |
13 <% @project.tasks.each do |t| %> | |
14 <%= t.name %> | |
15 <br/> | |
16 <% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment