0

I have been getting this error:

/home/shaili/project/app/models/inbox.rb:8: syntax error, unexpected end-of-input, expecting keyword_end

I am trying to add a search bar and have been also trying to set a path of the same page.

This is my models/inbox.rb file:

class Inbox < ActiveRecord::Base
  def self.search(search)
    if search
      find(:all, :conditions => ['name LIKE ?', '%#{search}%'])
    else
      find(:all)
    end
  end

This is the part of my Inbox_controllers file:

@inbox = Inbox.search(params[:search])

This is the part of my inbox.html.erb file where I am trying to figure out the path of the same page:

<%= form_tag :method => 'get' do %>
  <p>
    <%= search_field_tag :Search, params[:search] %>
    <%= submit_tag "Search", :name => nil %>
  </p>
<% end %>
1
  • If you indent your code you will spot this sort of error much more easily. Commented May 21, 2015 at 14:49

2 Answers 2

4

Missing an end at the end :) :

class Inbox < ActiveRecord::Base
  def self.search(search)
    if search
      find(:all, :conditions => ['name LIKE ?', '%#{search}%'])
    else
      find(:all)
    end
  end
end

Proper indentation will help you spot these errors even before you attempt to run.

Sign up to request clarification or add additional context in comments.

4 Comments

thank you. Everytime I try to search it redirect me to the homepage. Any tips on how to set a path?
Thats a separate question. I'd have to look at your complete controller code and perhaps the routes file to answer that question.
Do you need my controller or routes.rb file?
You should submit a new question with details about that problem as it is quite a separate issue from this one.
3

You are missing the end for class

class Inbox < ActiveRecord::Base
  def self.search(search)
    if search
      find(:all, :conditions => ['name LIKE ?', '%#{search}%'])
    else
      find(:all)
    end
  end
end

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.