undefined method `parameters' for nil:NilClass in rails 3 -


in rails app have 2 controllers coordinates , tweets , tables respectively.i have 2 text fields in search button , need fetch queries tweets table using conditions in coordinates table . getting error "undefined method `parameters' nil:nilclass" . coordinates_controller.rb

 class coordinatescontroller<applicationcontroller        def paramas(b)          @b = params[:show]         return @b        end       def coor(latitude,longitude)         @latitude=0`enter code here`         @longitude=0       end        def search       @a=coordinates.where(city: params[:show]).take         if(params[:show]== a.city)            @latitude= a.latitude           @longitude=a.longitude         end         if(@latitude=0 && @longitude=0)         return  @sql="select * tweets tweet_text '%search%' , user_loc 'a.paramas' order id desc"         else if (@latitude!=0 && @longitude!=0)                 @min_lat = @latitude - 1.0                @max_lat = @latitude + 1.0                @min_lng = @longitude - 1.0                @max_lng = @longitude + 1.0             return   @sql = "select * tweets tweet_text '%search%' , ( ((longitude between min_lng , max_lng) , (latitude between min_lat , max_lat)) or (user_loc 'a.paramas') ) order id desc"              else             return   @sql="select *  tweets tweet_text  '%search%'"              end              end       end           #  a= coordinatescontroller.new       end  class tweetscontroller<applicationcontroller require 'coordinates_controller.rb' #require 'models/coordinates.rb'    def index #include 'coordinates_controller.rb'     a= coordinatescontroller.new     @sql=a.search     @tweets=tweets.paginate_by_sql(sql, :@page, :per_page => @per_page ).all   end end view code search button <%= form_tag({controller: "tweets", action:"index" }, method: "get")  %> <%= label_tag(:search, "search for:") %> <%= text_field_tag(:search) %> <%= text_field_tag(:show) %> <%= submit_tag("get results ") %> <% end %> 

my view code display tweets

%= will_paginate @tweets %> <% @tweets.each |tweets| %> <ul> <li><%= tweets.id %></li> <li><%= tweets.tweet_created_at %></li> <li><%= tweets.tweet_id %></li> <li><%= tweets.tweet_source %></li> <li><%= tweets.tweet_text %></li> <li><%= tweets.user_id %></li> <li><%= tweets.user_name %></li> <li><%= tweets.user_sc_name %></li> <li><%= tweets.user_loc %></li> <li><%= tweets.user_img %></li> <li><%= tweets.longitude %></li> <li><%= tweets.latitude %></li> <li><%= tweets.place %></li> <li><%= tweets.country %></li> <% end %> </ul> 

iam stuck long time pls me proceed. thks in advance

suggestion: install dev gem better_errors: https://github.com/charliesome/better_errors

with nice console in browser when code fails. if you, insert bogus code:

#include 'coordinates_controller.rb'     a= coordinatescontroller.new     @sql=a.search     @tweets=tweets.paginate_by_sql(sql, :@page, :per_page => @per_page ).all     likethisboguscodeblablabla   end end 

to make sure fails after line, in console, check @tweets etc objects , on. repeat on every crucial line of code cause problem.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -