Thursday, 15 August 2013

mysql - Rails how to fix table to take any url -


In my records index.html.erb I have a table with titles, which are linked so that the table itself is ordered Will:

  & lt; Table class = "table-table-hover" id = "records" & gt; & Lt; Thead & gt; & Lt; TR & gt; & Lt; Th & gt; & Lt;% = sorted "first name", "frist name"%> & Lt; / Th & gt; & Lt; Th & gt; & Lt;% = sorted "last name", "last name"%> & Lt; / Th & gt; ...  

The sortable method represents the assistant in my app:

  def sortable (column, title = Zero) title || = Column.titleize if sort_column == column testvar = true end css_class = column == sort_column? "Current # {sort_direction}": zero direction = column == sorted column & amp; Sort_direction == "Esk"? "Desc": "asc" if testvar == true link_to title, {: sort = & gt; Column, direction = & gt; Direction}, {: class = & gt; 'BTN BTN-BTN-Default BTN-XS BTN-Success') and link-to-title, {: sort = & gt; Column, direction = & gt; Direction}, {: class = & gt; 'BTN BTN-Default BTN-XS'} End End  

The last product for both of them is the HTML code on the HTML page:

  & lt; Th & gt; & Lt; A class = "BTN BTN-Default BTN-X" href = "/ record? Direction = ACH and sort = last name" & gt; Last name & lt; / A & gt; & Lt; / Th & gt;  

In the right way ...

So if I go: it works fine, but if I go then I get an error. / P>

I have also installed a search bar on the same page:

  <% = form_tag records_path,: method = & gt; 'Get'% & gt; & Lt; P & gt; & Lt;% = text_field_tag: search, parameter [: search], autofocus: true% & gt; & Lt;% = submit_tag "Search",: name = & gt; Zero% & gt; & Lt; / P & gt; & Lt;% end% & gt;  

It works perfectly, when it searches, but if the search bar is empty and you click on the search button, it sends this URL: to send it to Similar error occurs

I get this error:

missing records Maybe this could be the cause of the problem?

So my question is:

How can I avoid this error?

Here's some more information that might be useful: My Record Controller:

  Def index if current_user.profile.title == "admin" @ Records = record.order (sort_column + "sort_direction) Otherwise if the consultation [: search]. Blank?? Parameters [: search] == '' @ Records = record.where (loanfauzer_rd: current_use.ed.) .corder (sorting ++ "Sort-Direction) Other @ Records = Record. Search (Param [: Search]) End & End   

My Records Model:

  def self.search (search) ") if results! Blank? Results and Results = where ('like the last name?',"% # {Search}% ") If the result! The result ends at the end of the other results and records all end and  

I Everyone was watching in the wrong places about my record controller and I forgot below: Param [: Sort]: "name" and deaf sort_driver% w [asc desc] include? (Param): [name]: Parameters [: sort:] Def sort_column Record.column_names.include? [: Direction]) Params [: direction]: "asc" and

What I had to do, "name" was replaced with "first name" and he fixed it for me .


No comments:

Post a Comment