i am using rails 2.3.4 and i am facing "no method error"
there is possibility to not find method but my question is - is there possibility to error occurred because of empty table? or error in another controller or helper?
error trace:
Processing QuoteRequestsController#create (for 127.0.0.1 at 2012-10-17 16:07:34) [POST]
Parameters: {"controller"=>"quote_requests", "quote_request"=>{"packing_required"=>"", "move_steps_number"=>"", "phone_day"=>"", "pickup_region_id"=>"", "email"=>"", "move_to_street"=>"", "move_from_suburb"=>"", "title"=>"", "quick_estimate"=>"true", "room_counts"=>{"9"=>"0", "8"=>"0", "5"=>"0", "2"=>"0", "3"=>"0", "6"=>"0", "7"=>"0", "1"=>"0", "4"=>"", "11"=>"0"}, "arrive_parking_notes"=>"", "first_name"=>"", "arrive_date_flexible"=>"false", "insurance_value"=>"", "arrive_steps_number"=>"", "move_parking_notes"=>"", "last_name"=>"", "move_region_id"=>"", "move_date_flexible"=>"false", "move_type_id"=>"26", "move_to_city"=>"", "arrive_date"=>"", "move_from_street"=>"", "move_date"=>"", "move_to_suburb"=>"", "move_from_city"=>"", "phone_mobile"=>""}, "authenticity_token"=>"U42qF1c0FJXvnC1SCNNYWzxKN3Pem7dC6L01LbTQD7E=", "commit"=>"Submit", "action"=>"create"}
NoMethodError (undefined method service_options' for nil:NilClass):
vendor/extensions/smartmove/app/controllers/quote_requests_controller.rb:136:inload_regions'
vendor/radiant/vendor/plugins/haml/rails/./lib/sass/plugin/rails.rb:19:in `process'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/server.rb:162:in `start'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/server.rb:95:in `start'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/server.rb:92:in `each'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/server.rb:92:in `start'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/server.rb:23:in `start'
/home/bacancy/.rvm/rubies/ruby-1.8.7-p370/lib/ruby/1.8/webrick/server.rb:82:in `start'
in "vendor/extensions/smartmove/app/controllers/quote_requests_controller.rb" line no:136 is
#regions = ServiceDescription.find_by_name('region').service_options
in my database table is there service_descriptions and service_options. is there related to mysql or controller?
please guide me i am very much confuse. this is existing application i have to configure in local as well as on server
Thank you in advance
Thanking You
Nirav
You are getting error because ServiceDescription.find_by_name('region') returns nil (This simply means you have no data in your service_descriptionstable with name 'region') and then you are calling service_options on it (i.e. nil)
Best way to avoid such case is to check if value is nil or not before applying any method it.
#regions = ServiceDescription.find_by_name('region')
#service_options = #regions ? #regions.service_options : nil
Related
I'm having an issue posting posts to a page, and only get the helpful error:
OAuthException :: (#1) An error occured while creating the share
The first 20 or so posts worked great, then it started to error.
Does facebook have a limit on the number of posts one can make to a page (spam) or something?
I can reproduce form rails c and I have triple checked my access_token and can manually post from FB directly.
(I'm using the page access_token not my user one)
I opened a issue on FbGraph's githup but nov seems to think its a FB issue.
My Code:
admin = Admin.first
page = FbGraph::Page.new(admin.facebook_page_id)
Story.where(:facebook_post_id => nil).all.each do |story|
post = page.feed!(
:link => 'http://www.example.com/stories/'+story.cached_slug,
:access_token => admin.facebook_page_access_token
)
story.facebook_post_id = post.identifier
story.live = true
story.save
sleep 1
end
Backtrace:
FbGraph::InvalidRequest: OAuthException :: (#1) An error occured while creating the share
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/fb_graph-2.6.4/lib/fb_graph/exception.rb:47:in `block in handle_httpclient_error'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/fb_graph-2.6.4/lib/fb_graph/exception.rb:44:in `each'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/fb_graph-2.6.4/lib/fb_graph/exception.rb:44:in `handle_httpclient_error'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/fb_graph-2.6.4/lib/fb_graph/node.rb:142:in `handle_response'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/fb_graph-2.6.4/lib/fb_graph/node.rb:55:in `post'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/fb_graph-2.6.4/lib/fb_graph/connections/feed.rb:14:in `feed!'
from (irb):9:in `block in irb_binding'
from (irb):5:in `each'
from (irb):5
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands/console.rb:47:in `start'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Update:
It looks like my access_token was banned for 24 hours.
I was just able to add another 28 posts to the page before getting this error again. I tried with a 10sec sleep this time but still got banned... I guess I will try with a 60sec sleep tomorrow.. :(
I was not able to fix this problem but I have worked around it.
By uploading 1 post every 3 minutes I was able to get 200-300 posts up a day.
admin = Admin.first
page = FbGraph::Page.new(admin.facebook_page_id)
Story.where(:facebook_post_id => nil).all.each do |story|
post = page.feed!(
:link => 'http://www.example.com/stories/'+story.cached_slug,
:access_token => admin.facebook_page_access_token
)
story.facebook_post_id = post.identifier
story.live = true
story.save
sleep 180
end
I hope this helps someone else with this problem.
Im getting a weird string error when trying to assign attributes on a Rails model:
# POST /apartments
# POST /apartments.xml
def create
#apartment = Apartment.new(params[:apartment])
Params
{"utf8"=>"✓",
"authenticity_token"=>"Kxxxxx=",
"apartment"=>{"street"=>"123 Main St",
"unit"=>"",
"hide_address"=>"0",
"city"=>"White Plains",
"state"=>"New York",
"zipcode"=>"10840",
"country"=>"United States",
"price"=>"4000",
"security_deposit"=>"",
"application_fee"=>"",
"bedrooms"=>"4",
"bathrooms"=>"3",
"size"=>"",
"available_date"=>"",
"unit_amenities"=>["air conditioning"],
"description"=>"",
"rooms"=>"1"},
"commit"=>"Publish Your Listing"}
Error
NoMethodError in ApartmentsController#create
undefined method `each' for "1":String
Thoughts?
I'm running Rails 3.1.1 and getting an odd bug. In development (haven't yet tried pushing to production with it) I'm occasionally getting routing errors in my controller or in my mailer template when it tries to generate a url for a newly created record. This happens even though the record is created successfully and appears to have nothing to do with the record properties (I can recreate a record with the exact same params right after and not get the error, it seems totally random when it happens).
It seems to happen maybe one in 10 times, though I can't say I ever saw an incident of it happening before I added the mailer action.
There's one more potentially complicating factor: I'm using an encryption method to obfuscate the record's id in its URL, but this is otherwise working without a hitch. To do this I adapted the method discussed here
It seems to me like the URL's not generated in time for the link_to call some of the time... But that doesn't make much sense to me. I didn't think race conditions were something I needed to worry about here.
Here are my error logs when this happens in the controller (when the params don't call for an email to be generated):
ActionController::RoutingError (No route matches {:action=>"show", :controller=>"watch_lists", :id=>#<WatchList id: 195, title: "sfdsfd", created_at: "2012-03-19 05:18:46", updated_at: "2012-03-19 05:18:46", public_list: false>}):
app/controllers/watch_lists_controller.rb:72:in `block (2 levels) in create'
app/controllers/watch_lists_controller.rb:56:in `create'
And here's when it happens in the mailer template (when the params do call for an email to be generated before the render command):
Rendered watch_list_mailer/share_notification.html.erb (3.2ms)
Completed 500 Internal Server Error in 113ms
ActionView::Template::Error (No route matches {:action=>"show", :controller=>"watch_lists", :id=>#<WatchList id: 210, title: "sdggsgsg", created_at: "2012-03-19 05:47:17", updated_at: "2012-03-19 05:47:17", public_list: true>}):
20: <% end %>
21: <% end %><br>
22: <br>
23: Here's a link to your WatchList: <%= link_to #wl.title, watch_list_url(#wl) %><br>
24: <br>
25: Enjoy!
26: </p>
app/views/watch_list_mailer/share_notification.html.erb:23:in `_app_views_watch_list_mailer_share_notification_html_erb___1391186431365383285_70156615518000'
app/mailers/watch_list_mailer.rb:12:in `share_notification'
app/controllers/watch_lists_controller.rb:124:in `share_notification'
app/controllers/watch_lists_controller.rb:68:in `block (2 levels) in create'
app/controllers/watch_lists_controller.rb:63:in `each'
app/controllers/watch_lists_controller.rb:63:in `block in create'
app/controllers/watch_lists_controller.rb:56:in `create'
EDIT: Upon further testing, this appears to happen regardless of whether I include the mail task. It seems most likely spurred by the obfuscation of the links. It's possible that the encoding of the links has something to do with it (I had to make sure to URI-escape them to prevent slashes in the wrong places elsewhere in my code). I'll investigate this futher and report back.
It was a problem with the id encryption creating invalid links occasionally and me failing to account for that in early enough in the process.
In lib/obfuscate.rb
def uri_encrypt(value)
URI.escape(self.encrypt(value), Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
end
In my model
def to_param
uri_encrypt(id)
end
I am using the 0.5.5 version of the gcal4ruby gem on my rails 3.0 app and I am
seemingly having trouble creating an event. I can start service, and
create a calendar just fine, but I get the following error when I try
to create an event:
NoMethodError: undefined method `debug' for #<GCal4Ruby::Calendar:
0x1036d8a68>
from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/
event.rb:242:in `to_xml'
from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/
event.rb:236:in `map'
from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/
event.rb:236:in `to_xml'
from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/
event.rb:230:in `create'
from /opt/local/lib/ruby/gems/1.8/gems/gdata4ruby-0.1.5/lib/
gdata4ruby/gdata_object.rb:155:in `save'
from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/
event.rb:225:in `save'
from (irb):92
I looked at the code in this line, and it seems like it is checking
whether or not the service.debug = true, not the calendar, so i'm not
sure why it is throwing this error. Here's how I got here in IRB,
line by line:
service = GCal4Ruby::Service.new
service.authenticate(MY_GOOGLE_LOGIN, MY_GOOGLE_PASS)
calendar = GCal4Ruby::Calendar.find(service, 'Test 2', :first)
event = GCal4Ruby::Event.new(calendar)
event.title = "test title"
event.content = "test content"
event.where = "my house"
event.start = Time.now
event.end = 2.hours.from_now
event.all_day = false
event.calendar = calendar[0]
event.save
NoMethodError: undefined method `debug' for #<GCal4Ruby::Calendar:
0x1036d9990>
from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/
event.rb:242:in `to_xml'
from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/
event.rb:236:in `map'
from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/
event.rb:236:in `to_xml'
from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/
event.rb:230:in `create'
from /opt/local/lib/ruby/gems/1.8/gems/gdata4ruby-0.1.5/lib/
gdata4ruby/gdata_object.rb:155:in `save'
from /opt/local/lib/ruby/gems/1.8/gems/gcal4ruby-0.5.5/lib/gcal4ruby/
event.rb:225:in `save'
I must be missing something here, but I'm not sure what. Obviously I
am getting a valid calendar object...is there some attribute that I am
missing?
Alternatively, if anyone has any other suggestions as to what to use for a calendar solution I would love to hear it. Basically I need to allow users to add predefined events to a calendar, which can be recurring, and ideally I'd like for them to be able to export these calendars for use in outlook, ical, etc... Is there a way to do this via web?
Thanks!
well this is annoying, i seem to have it working. it was a matter of changing:
event = GCal4Ruby::Event.new(calendar)
to
event = GCal4Ruby::Event.new(service)
even though that's directly contrary to what i had read in the documentation.
EDIT:
Got too confusing with so many different edits, so this is where I'm currently at.
I have a HTTPService in my Flex 4 app defined as follows:
<s:HTTPService id="getUserDetails" url="http://localhost:3000/users/getDetails" method="GET"/>
I call this service like this (note: I've checked the network monitor in Flash Builder 4 and the userNameLookup variable is sent correctly):
var userNameLookup:String;
userNameLookup = calleeInput.text;
getUserDetails.send(userNameLookup);
And finally, this is the Ruby on Rails method:
def getDetails
#user = User.find_by_username(:userNameLookup)
render :xml => #user
end
This is the error message in the log:
Processing UsersController#getDetails
(for 127.0.0.1 at 2010-04-27 19:24:23)
[GET] User Load (0.2ms) SELECT *
FROM "users" WHERE ("users"."username"
= '--- :userNameLookup ') LIMIT 1
ActionView::MissingTemplate (Missing
template users/getDetails.erb in view
path app/views):
app/controllers/users_controller.rb:33:in
getDetails'
app/controllers/users_controller.rb:32:in
getDetails'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in
service'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in
run'
/usr/local/lib/ruby/1.8/webrick/server.rb:173:in
start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in
start'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in
start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:95:in
start'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in
each'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in
start'
/usr/local/lib/ruby/1.8/webrick/server.rb:23:in
start'
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in
start'
So it appears that the userNameLookup parameter isn't being referred to correctly?
Just a thought, but does it matter that I've set the HTTPService to GET even though it is posting something?
The controller action methods should be implemented without parameters. The parameters can be inferred from the request parameters.
Try this:
def getDetails
#user = User.first(:conditions => {:username => params[:lookupUsername]})
respond_to do |format|
format.xml { render :xml => #user }
end
end
In the code above I have used lookupUsername as the query parameter. Change that to the actual name sent by your flex client.
Edit 1
You need explicit xml format handler to return the result as XML. Apart from this, it looks like lookupUsername parameter is empty in your invocations. Is it possible that the query parameter is named something else? You can get the name of the query parameter by looking at the log file. Your log file should show an entry like this:
Processing xxxxController#getDetails (for 127.xxx at 2010-04-15 10:27:21) [GET]
Parameters: {"action"=>"getDetails", "controller"=>"xxxx",
"lookupUsername" => "bob"}