Last active
August 29, 2015 14:06
-
-
Save Choongkyu/3ed171d5d3952de1a009 to your computer and use it in GitHub Desktop.
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
<title>Shared Todo App</title> | |
<div class='container'> | |
<div class='row'> | |
<div class='span4'> | |
<h1>Shared Todo App</h1> | |
<hr> | |
<%= form_for @todo do |i| %> | |
<%= i.text_field :name %> | |
<%= i.submit %> | |
<% end %><!--do1--> | |
<p>All your todos here</p> | |
<div class='well'> | |
<%= form_tag('/todos/complete', :method => 'post') do %><!--do2--> | |
<ul style="list-style-type:none"> | |
<% @todoAll.each do |t| %><!--do3--> | |
<li> | |
<% if t.completed == false %> | |
<%= t.name %> | |
<% else %> | |
<strike><%= t.name %></strike> | |
<% end %><!--if--> | |
<%= link_to 'Completed?',complete_todo_path(t), :method => :put %> | |
<%= link_to 'Delete item',t, :method => :delete %> | |
</li> | |
<% end %><!--do3--> | |
</ul> | |
<% end %><!--do2--> | |
</div> <!--well--> | |
</div> <!--span4--> | |
</div> <!--row--> | |
</div><!--container--> | |
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
class Todo < ActiveRecord::Base | |
belongs_to :user | |
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
class TodosController < ApplicationController | |
def index | |
@todoAll = Todo.all | |
@todo = Todo.where(completed:false) | |
@completes = Todo.where(completed:true) | |
end | |
def todoParams | |
params.require(:todo).permit(:name, :completed) | |
end | |
def destroy | |
@todo = Todo.find(params[:id]) | |
@todo.destroy | |
redirect_to :action => 'index' | |
end | |
def create | |
@todo=Todo.new(params) | |
@todo.userID = current_user | |
@todo.completed = false | |
@todo.save | |
redirect_to :action => 'index' | |
end | |
def complete | |
@todo = Todo.find(params[:id]) | |
if @todo.completed == false | |
@todo.update_attribute(:completed, true) | |
else | |
@todo.update_attribute(:completed, false) | |
end | |
redirect_to :action => 'index' | |
end | |
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
ActionController::ParameterMissing in TodosController#add | |
param not found: todo | |
Extracted source (around line #10): | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
def todo_params | |
params.require(:todo).permit(:name, :completed) | |
end | |
def destroy | |
Rails.root: C:/Users/Quilty-dell/rails_projects/shared_todo_app | |
Application Trace | Framework Trace | Full Trace | |
app/controllers/todos_controller.rb:10:in `todo_params' | |
app/controllers/todos_controller.rb:27:in `add' | |
Request | |
Parameters: | |
{"utf8"=>"✓", | |
"authenticity_token"=>"5Ucb6+53IKKe2Ogz0KY6AgKVbZwFREJi23yLXBNzL0k=", | |
"todo_text"=>"sdf", | |
"commit"=>"Add todo"} | |
Toggle session dump | |
Toggle env dump | |
Response | |
Headers: | |
None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment