# Add a task to todo

**URL:** <https://www.ruby-forum.com/t/add-a-task-to-todo/102412>\
**Category:** Ruby\
**Created:** [December 5, 2005, 8:11pm UTC](https://www.ruby-forum.com/t/add-a-task-to-todo/102412 "2005-12-05T20:11:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevanicus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@stevanicus](https://www.ruby-forum.com/u/stevanicus)\
**Post date:** [December 5, 2005, 8:11pm UTC](https://www.ruby-forum.com/t/add-a-task-to-todo/102412/1 "2005-12-05T20:11:06Z")

</div>

hmm no i cant get something else to work

in my controller

```
def add_tasklist
	tasklist = Tasklist.new
	tasklist.attributes = @params["new_tasklist"]

	if tasklist.save
		redirect_to(:action => "list")
	else
		render_text"could not add"
end

```

in my template

New Task: \<%= text\_field("new\_tasklist", "task") %\>

my database is todo, the table is tasklist, fields are id, task, done

and i get the following error

SyntaxError in #

./script/…/config/…/app/controllers/tasklist\_controller.rb:17: syntax  
error

ive tried changing the tasklist to tasklists, im not quite sure what  
that means why some are tasklists and some tasklist.

thanx

Steve

---

<div class="post-metadata">

**Author:** ![stevanicus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@stevanicus](https://www.ruby-forum.com/u/stevanicus)\
**Post date:** [December 5, 2005, 8:17pm UTC](https://www.ruby-forum.com/t/add-a-task-to-todo/102412/2 "2005-12-05T20:17:23Z")

</div>

On Dec 5, 2005, at 11:11 AM, steven masala wrote:

> hmm no i cant get something else to work
> 
> in my controller

Can you please take your Rails questions to the Rails mailing list?

[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Eric H. - removed\_email\_address@domain.invalid - [http://segment7.net](http://segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)

---

<div class="post-metadata">

**Author:** ![stevanicus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f0a364/32.png) [@stevanicus](https://www.ruby-forum.com/u/stevanicus)\
**Post date:** [December 5, 2005, 9:14pm UTC](https://www.ruby-forum.com/t/add-a-task-to-todo/102412/3 "2005-12-05T21:14:28Z")

</div>

In general, I agree with Eric H., you need to take Rails questions  
to the Rails mailing list. However, since it’s sitting right there, I  
will point out the probable culprit:

> ```
> if tasklist.save
> redirect_to(:action => "list")
> else
> render_text"could not add"
> 
> ```

should be

if tasklist.save  
redirect\_to(:action =\> “list”)  
else  
render\_text “could not add”  
end # \<= added this

In ruby, unlike C or PHP or other languages, the if statement always  
has the “end” keyword as a terminator.

Jacob F.
