When i include fb_connect_async_js javascript helper it is throwing an
error , Facebooker 2 don't have action view template. Could you please tell
me how handle this situation .
undefined local variable or method `fb_connect_async_js' for
ActionView::Base
Thanks,
Srini
try add require 'facebooker2' in environment.rb and rake gems:install
Related
I'm working on a Ruby on Rails app that is using Webpacker. I get a strange undefined method error when using asset_pack_path - a NoMethodError is thrown and says undefined method 'asset_path' Did you mean? asset_pack_path. This is a similarly named method but not the one I am calling; asset_path does not appear in the app's codebase either.
I believe to be calling the correct path inside of asset_pack_path but that does not seem to be consistent with the error. Perhaps there is a versioning mis-match somewhere? I am at a loss with this one. Any ideas or suggestions to resolve this undefined method error and use asset_pack_path would be helpful.
Thanks!
You are trying to call Rails Views helper method inside a Controller.
Try: ActionController::Base.helpers.asset_pack_path
It turned out that asset_path was called inside the asset_pack_path method - both ActionView::Helpers::AssetUrlHelper Webpacker::Helper need to be included for asset_pack_path to work
If I know the class name I can do something like TheClassName.method(:mail).source_location but I don't know the class name the method belongs to.
Where is 'mail' defined? method(:mail) raises
NameError: undefined local variable or method `mail' for main:Object
but its written just as mail(*args, &block) in the code.
bundle open rails was not particularly helpful as there was just a readme...
going up a directory and rummaging around I stumbled across actionmailer directory.
Its in ActionMailer::Base, but unless you know that in advance, I don't know how you would search for it
I was following the guide I found online to put ActiveAdmin and TinyMCE together into use, but I encountered a strange error which I was not able to search up the solution for it.
One part of it was to add in this line to config/initializers/active_admin.rb:
config.register_javascript 'tinymce.js'
However, when I try to run the app, an error says:
/Users/RageBill/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/bundler/gems/activeadmin-5ebf476abd92/lib/active_admin/application.rb:49:in method_missing': undefined methodregister_javascript' for # (NoMethodError)
Any thoughts on how can I resolve this problem? Thank you very much :)
(P.S. my rails version is 5.1.3 if that would be helpful.)
I found:
https://github.com/activeadmin/activeadmin/issues/340
This sholud work:
ActiveAdmin.setup do |config|
config.register_stylesheet "//cdn.foo.net/example.css"
config.register_javascript "//cdn.foo.net/example.js"
# ...
end
Greeting all...
I'm trying to figure out a problem that I've never seen and shouldn't be happening by all accounts...
I'm using Rails 3.0.12 with a simple/standard ActionMailer setup:
I have HelpRequestMailer in app/mailers
I have HelpRequestsController in app/controllers
First problem... When I call the mailer in my controller...
help_request = HelpRequest.new(params[:help_request])
...
HelpRequestMailer.help_request_email(help_request).deliver
I get the following error: NameError (uninitialized constant HelpRequestsController::HelpRequestMailer)
This in itself is strange.
When I add the following...
require File.expand_path('../../mailers/help_request_mailer', FILE)
...To the top of the controller (I would expect the path to be '../mailers/help_request_mailer' but that doesn't work) - which I shouldn't have to do - the controller seems to find the mailer but doesn't seem to recognize what it is/know what to do with it. I get the following error:
NoMethodError (undefined method `help_request_email' for HelpRequestMailer:Class)
Which is technically true... There's no help_request_email class method in HelpRequestMailer... It's an instance method (as specified by the documentation).
My ActionMailer configuration lives in config/application.rb
Any help/suggestions would be greatly appreciated...
I had this problem too, and it turned out to be a case of a completely unhelpful error message. In my case it was just a syntax error in some of my code for the action mailer or the associated view.
I think what happened is that when Rails couldn't properly parse the mailer or view code, it just bypassed the files and never instantiated the action mailer object, leading to the error in the controller.
I would have much preferred it if Rails had tripped on the error in the action mailer code itself.
I am using sidekiq gem in rails 3 and I have define a foo_workers.rb in app/workers folder, when I try to call FooWorker.perform_async(#article) in a rails controller named articles I get this error,
uninitialized constant ArticlesController::FooWorker
Can anyone please help me.
Check your pluralization. The file is called foo_workers.rb, which means you're probably defining FooWorkers, not FooWorker. It should be singular. But this is all guessing because you didn't actually post any code.
The autoload mechanism won't pluralize your class names. So the class FooWorker is expected to be defined in a foo_worker.rb file in some of the autoload paths.
If the file name is different (like foo_workers.rb), Rails won't try to load the class from it.