i have a link where it has to call a method defin in todoscontroller
named say_when but show is called
<td><%= link_to 'Say when', todo, :action => :say_when ,
:remote => true %></td>
class TodosController < ApplicationController
# GET /todos
# GET /todos.xml
def index
@todos = Todo.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @todos }
end
end
# GET /todos/1
# GET /todos/1.xml
def show
@todo = Todo.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @todo }
end
end
# GET /todos/new
# GET /todos/new.xml
def new
@todo = Todo.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @todo }
end
end
# GET /todos/1/edit
def edit
@todo = Todo.find(params[:id])
end
# POST /todos
# POST /todos.xml
def create
@todo = Todo.new(params[:todo])
respond_to do |format|
if @todo.save
format.html { redirect_to(@todo, :notice => 'Todo was
successfully created.') }
format.xml { render :xml => @todo, :status => :created,
:location => @todo }
else
format.html { render :action => "new" }
format.xml { render :xml => @todo.errors, :status =>
:unprocessable_entity }
end
end
end
# PUT /todos/1
# PUT /todos/1.xml
def update
@todo = Todo.find(params[:id])
respond_to do |format|
if @todo.update_attributes(params[:todo])
format.html { redirect_to(@todo, :notice => 'Todo was
successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @todo.errors, :status =>
:unprocessable_entity }
end
end
end
# DELETE /todos/1
# DELETE /todos/1.xml
def destroy
@todo = Todo.find(params[:id])
@todo.destroy
respond_to do |format|
format.html { redirect_to(todos_url) }
format.xml { head :ok }
end
end
def say_when
puts "hey i am callinf from ajax request"
respond_to do |format|
format.html { render(:layout => false) }
end
end
end
here is teh view
<h1>Listing todos</h1>
<table>
<tr>
<th>Tarea</th>
<th>Progreso</th>
<th>Show</th>
<th>Edit</th>
<th>Destroy</th>
<th>Add</th>
<th>Less</th>
</tr>
<% @todos.each do |todo| %>
<tr>
<td> <%= todo.todo %></td>
<td>
<span class='progressBar' id='element<%= todo.id %>'><%=
todo.progreso %></span>
</td>
<td><%= link_to 'Show', todo %></td>
<td><%= link_to 'Edit', edit_todo_path(todo) %></td>
<td><%= link_to 'Destroy', todo, :confirm => 'Are you sure?',
:method => :delete %></td>
<td><%= link_to 'Say when', todo, :action => :say_when ,
:remote => true %></td>
<td></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Todo', new_todo_path %>
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.