how to use gem doc_ripper with external links - ruby-on-rails

So I am trying to use the doc_ripper gem and as per whats written all the requirements work fine.
What I am trying to implement is that instead of path to local file, I would like to include path to url of the file.
When I tried to run the command --> DocRipper::rip('/path/to/file')
for the external link it gave me the following error
DocRipper::rip(s3storageurl)
NoMethodError: undefined method `rip' for nil:NilClass
I would like to know if anybody is using the above gem and is able to pass urls

Related

Ruby on Rails - undefined local variable or method - wice grid haml show_code

I am new to ruby on rails.
I am trying to get haml and wice_grid to work together. I am using this example as a model:
http://wicegrid.herokuapp.com/basics3
I get the error 'undefined local variable or method `show_code' for...'
In the file app/views/basics3/index.html.haml which you can see at the link above.
Am I missing a gem? In general, what is the best way to troubleshoot problems like this?
Thanks in advance-
Flex
EDIT: I found the definition for show_code. It's in a helper that I found in the unit tests for wice_grid.
https://github.com/leikind/wice_grid_testbed/blob/master/app/helpers/application_helper.rb
That said, I get more errors when I load it into my project. So the question becomes, how does the helper normally get included in my project?
show_code is a custom method created just for the example page you linked to. It just displays the code he has in his controller and his index and grid views. You don't need to call that method in your own application so just remove that line and you should be good.

Trying to use coffeescript in a rails engine

I'm trying to use some coffee script in an engine but as soon as i name a file with:
*.js.coffee or *.coffee
an error is triggered and i can't load the page:
ExecJS::RuntimeError at /mylocation
SyntaxError: unexpected IDENTIFIER
The page won't load. My coffeescript is working in another app (Actually i'm trying to extract the logic from the main app to an engine). When i try using it in the engine it failed if it's a .coffee file.
I have in gemfile of the core app:
gem 'coffee-rails'
In the engine gemspec:
s.add_dependency 'coffee-rails'
If i rename the file to *.js the page loads but of course i see the syntax error in the js console.
Any idea where i should look or what should i do to use coffeescript in my engine ?
"Unexpected identifier" means that you have a variable you're trying to reference that hasn't been declared. Possibly a function which is not within the coffescript callback?
Make sure you pass all the variables you're trying to use.
I find my stupid error, the file i was playing with was and old js file and when i converted it to coffee i forgot to change the comments lines ( // to # )...

undefined local variable or method `sign_out_path'

I'm beginner in rails application. I have used devise gem to authentication purpose.
when I log in its showing error:
undefined local variable or method `sign_out_path'
How can I solve this problem?
There could be two reasons for this:
You have not got the correct routes defined in your routes configuration file
You have used a path helper for an existing route but mistakenly used the wrong name
First run rake routes. Have a look through the output and see if you can see any routes beginning with "devise".
If you can see one called "destroy_user_session" then this is actually the name you need to use for your sign out link, and not "sign_out_path". In that case, go to the view where you have put your sign out link and replace the helper with "destroy_user_session_path".

Rails.root being overwritten by Amazon AWS-SDK gem?

I see this error:
undefined method `root' for AWS::Rails:Module
The corresponding line in my controller:
directory_name = Rails.root.join('public', #curAdmin.name)
This worked fine until I recently added the aws-sdk gem to my application to push static files and assets over to my S3 bucket.
Now it seems like when I call "Rails" the application thinks I'm referring to an AWS class method.
I don't know how I tripped the system up to do this.
This will happen if you refer to Rails within the AWS namespace. You should be able back out of the namespace by prepending :: to the module - ie ::Rails.root.join('public', #curAdmin.name)
I don't know why I tripped everything up - but if I remove the include at the top of the controller:
#include AWS
And then I refer to such methods directly as:
s3 = AWS::S3.new
bucket = s3.buckets['my_bucket_here']
It works ok. I'd still like to know what I did wrong.

Rails: how do you access RESTful helpers?

I'm trying to work through this guide to Rails routing, but I got stuck in section 3.3:
Creating a RESTful route will also make available a pile of helpers within your application
and then they list some helpers like photos_url, photos_path, etc.
My questions:
Where can I find the complete list of helpers that is "made available?"
Is there a way to call the helpers in the console? I created an app, then opened up the console with script/console. I tried to call one of the helpers on the console like this:
>> entries_url
But got:
NameError: undefined local variable or method `entries_url' for #<Object:0x349a4>
from (irb):8
You have several questions in there, most of which have already been answered by people below.
The answer to one that wasn't fully addressed however, is: yes you can use the script/console to see where your routes go. Just type in app.[route_helper] and it will respond with the path. For example app.users_path will return /users/
So for your example type app.entries_url for the full URL - or app.entries_path for its relative path within the console.
rake routes at the command line should get you that list.
I think this may be what you are looking for ... http://topfunky.com/clients/peepcode/REST-cheatsheet.pdf
You can access other helpers in the console by prepending "helper."; ie. helper.progress_box (assuming #progress_box exists of course)
From memory, you can't call url/path helpers from the console for some reason.

Resources