Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 months ago.
Improve this question
So I was learning ruby and practicing reverse engineering a ruby app and i found this line :
include ::Pro::License
I need to know what does it include because I am finding any file or folder name Pro or License
If it was a class I want to view the class
Although there exist some conventions for files to be named after the classes/modules they define (and constants autoloading magic, in Rails in particular, relies on these conventions), Ruby itself, as a language, doesn't enforce this in any way. So one can define class Bar in path/to/foo file, require the latter explicitly and then include Bar - everything will just work, for good or bad.
The module you include might be defined in some gem - and some of (most of?) the IDEs don't search the gems source code by default.
So, what to do. If you are on a relatively fresh Ruby (2.7+) there is a method Module#const_source_location that can help you to locate where the particular constant comes from (try self.class.const_source_location("::Pro::License") in the console). That's probably the shortest path.
If your Ruby is older, try pry (or pry-rails if it's Rails) code browsing capabilities. Drop a breakpoint (binding.pry) somewhere in the app, then cd ::Pro::License, then show-source (dash, not underscore!). It should print the source code of the module along with the full path to the file where it is defined.
If none of the methods above works for you for whatever the reason, then your IDE advanced search (or grep) is your only friend (just ensure you're searching not only through the project folder but through gems too).
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I am a beginner just starting to learn ruby. The tutorials I have been reading say that I can create a file with the extension .rb(eg. hello.rb) and run the file in the command prompt by typing ruby hello.rb. But when I create and save the file on the desktop and run it in the cmd it always gives me this error message:
C:\Windows\system32>ruby hello.rb
Traceback (most recent call last):
ruby: No such file or directory -- hello.rb (LoadError)
I searched the internet and read a lot of other tutorials but none of them seem to have any discussion on this issue.
Can someone give me any hints on this please?
Any advice or help will be greatly appreciated!
You should provide the correct path to your file, since it's not located in system32 directory, this relative path won't work. If it's on the desktop, it would be something like this, probably:
ruby %HOMEPATH%\Desktop\hello.rb
or you can change your current directory to desktop before you start playing with ruby:
cd %HOMEPATH%\Desktop
from now on, you can easily use relative path, since hello.rb is located in the same directory you're in currently in your command line:
ruby hello.rb
I'm not quite sure of exact syntax etc, I don't use Windows cmd very often - you would have to experiment on your own.
There may be context menu option like "open command line here" in Windows, but I'm not sure of it as well.
Also, you may need to learn basics of command line even before you start to learn Ruby.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
Production, and development work just fine, but the test environment doesn't want to migrate.
Does anyone have any idea as to why the gem is not working for the migration?
Did you run bundle exec rspec:install ?
In case you have multiple versions of rspec, you can try bundle exec rspec so it calls the one defined in your Gemfile.
Instead of require, try require_relative, that way, the path is resolved regardless of the location from which you're calling the script.
I ended up removing the repo, and deleting my database then re-installing everything which seemed to do the trick.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm following Michael Hartl's RoR Tutorial and in Lesson 6 he opens the database using the Cloud 9 IDE. I'm using Sublime Text 3 and I can't figure out how to download the development.sqlite3 file. Is it possible to download a database file and open it Sublime Text 3?
You can try to manually load the sqlite3 module (instructions for MacOS)
Copy the entire sqlite3 folder from
/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3
to your Sublime Text 3 folder
Then copy
/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/lib-dynload
To the same folder
finally on Sublime click View -> Show Console and then type
import sqlite3
If you're working in a Rails project using SQLite, the development.sqlite3 file should already be generated in the db directory within your project - there's no need to download it.
Opening the file itself in Sublime would probably not be very useful to you as it's going to be a huge series of unreadable characters representing the db. If you want to interface with the data within your db, here are some options:
rails dbconsole - this command figures out which database you're using and drops you into whichever command line interface you would use with it. Once you're in the CLI, you can perform SQLite commands, such as getting lists of records from tables, making changes to data, etc. - more info
rails console - assuming you have the proper models and database adapters configured, you can always drop into the Rails console - rails c - and use ActiveRecord to make some basic calls to the database. - more info
SQLite GUIs - there are many applications out there that provide a nice tabular user interface to interact with the data in your db. Some cross-platform examples for SQLite are:
SQLite Studio - http://sqlitestudio.pl/
SQLite Browser - http://sqlitebrowser.org/
Hope this helps!
I am often pointed to the source of typo blog engine i.e., http://typosphere.org/stable.tar.gz But, if I download and perform the following: bundle install etc. it runs as a separate engine.
I tried installing typo as a gem, I tried the following:
gem install typo
typo install /some/path this fails, saying 'Typo command not found'
How to integrate typo blog engine with existing app, any pointers would be welcome.
Typo is a Rails project. I am happy to say that I contributed to it at one point of time.
You asked in comments, that you wish to use database of Typo in your main application. For that, I'll suggest you to check out connection_ninja.
However, there are many gotchas with these type of configurations.
Good luck.
PS: Just noticed that this question was asked long ago. Ouch!
I know this is common in 'full featured' IDE's and not text editors but TextMate walks a unique line with its many bundles... I'm wondering if there is an easy way to, say, click on a Ruby or Rails class or method and have TextMate (or shell) take me to the definition or some documentation?
There's one built into the rails bundle (^h) which uses api dock.
Another pretty nice way of doing it is using the rails os x dictionary, but it has a few downsides and I'm not sure what version of rails it's using (I'm pretty sure it's not rails 3, but I haven't checked).
Ctrl-H is an excellent option to learn about Ruby or Rails API.
But this doesn't work for any other methods or class that may be defined or included in your project. For those I've written a TextMate Bundle command (you can easily assign it to Ctrl+] for example) that lookup for the definition of the class or method under the caret and displays it in a tooltip, along with the file name and the line where it was find.
Check it out: Add a shortcut to TextMate to lookup a class or method definition in a tooltip
Hope you'll find it useful ;)