I tried posting this in the Ruby on Rails talk group but haven't been
able to get a decent reply. Sorry if this isn't the appropriate place
to be posting this (if someone could tell me where I can post it, I'd
be more than happy to move it).
I can't get the autocomplete feature of script.aculo.us to work. I
have tried every guide I could find and several books to no avail.
As you can probably tell from the code, I'm new to this and just used
the scaffolding feature to setup a framework I was planning on
altering. Things I've tried so far to no avail are removing the
auto_complete function from the controller and removing the
javascript_include_tag from the view. Regardless of those changes,
when I type the first letters of a valid name into the
text_field_with_auto_complete it does not give me any suggestions. Any
help would be most appreciated!
Below are excerpts from my controller and my view file:
##########################
#ErrorsController
##########################
class ErrorsController < ApplicationController
auto_complete_for :error, :name
# GET /errors
# GET /errors.xml
def index
@errors = Error.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @errors }
end
end
# GET /errors/1
# GET /errors/1.xml
def show
@error = Error.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @error }
end
end
# GET /errors/new
# GET /errors/new.xml
def new
@error = Error.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @error }
end
end
# GET /errors/1/edit
def edit
@error = Error.find(params[:id])
end
# POST /errors
# POST /errors.xml
def create
@error = Error.new(params[:error])
respond_to do |format|
if @error.save
flash[:notice] = 'Error was successfully created.'
format.html { redirect_to(@error) }
format.xml { render :xml => @error, :status
=> :created, :location => @error }
else
format.html { render :action => "new" }
format.xml { render :xml => @error.errors, :status
=> :unprocessable_entity }
end
end
end
# PUT /errors/1
# PUT /errors/1.xml
def update
@error = Error.find(params[:id])
respond_to do |format|
if @error.update_attributes(params[:error])
flash[:notice] = 'Error was successfully updated.'
format.html { redirect_to(@error) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @error.errors, :status
=> :unprocessable_entity }
end
end
end
# DELETE /errors/1
# DELETE /errors/1.xml
def destroy
@error = Error.find(params[:id])
@error.destroy
respond_to do |format|
format.html { redirect_to(errors_url) }
format.xml { head :ok }
end
end
end
#######################
#index.html.erb
#######################
<h1>Listing errors</h1>
<table>
<tr>
<th>Name</th>
<th>Description</th>
<th>Solution</th>
</tr>
<%= javascript_include_tag :defaults %>
<%= text_field_with_auto_complete :error, :name %>
<% for error in @errors %>
<tr>
<td><%=h error.name %></td>
<td><%=h error.description %></td>
<td><%=h error.solution %></td>
<td><%= link_to 'Show', error %></td>
<td><%= link_to 'Edit', edit_error_path(error) %></td>
<td><%= link_to 'Destroy', error, :confirm => 'Are you
sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New', new_error_path %>
#######################
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Deploying Rails" 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-deployment?hl=en
-~----------~----~----~----~------~----~------~--~---