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!
Related
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).
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 5 years ago.
Improve this question
The message I'm getting after running migration command
The db file created after runnig above command is as below
[enter image description here][2]
Error I'm getting while trying to connect with table(demo) in database demo:
let me explain about your error message and your understanding above, when you typed rails generate migration demo (this is from your picture) and then the command line showing the file created, it does not meant the db file created, rails generate migration command usually to add/remove fields from existing table, it's just empty file that that you should put some additional command inside, check db/migration folder,
I believe this getting started with rails can help you.
basically for database steps
Create database file first with rake db:create
create your model with rails generate model Demo, again file created but you have to put some fields inside, check db/migration folder after you run this command
after you put fields then run rake db:migrate
if you missed some fields then you can add additional fields with rails generate migration AddDateToDemo
then put some fields inside and then run rake db:migrate, it's script for rails to execute job database creation/add/remove fields
I am learning RoR using M Hartls Rails tutorial book. I am very much new to the world of databases. I created the application(simple one, just on 3rd chapter) and did my RSpec and made few static pages. I wanted to migrate from sqllite3 to postgres.
I changed the database.yml to postgres deleting the full sqlite3 specifications. Now I run my app it does not work? It says 'PG:' Error.
I need to first understand how the data is stored in sqlite? I searched the db directory and I could not find the development.rb or any database file (probably because I altered the database.yml file)
In this case, I did not enter any data as such,(it still does not work , gives me error) but generally, where does the data get stored? and since I changed the database.yml file to postgres, what will happen to the existing data?
what does rake db:migrate command do?
It would be great if someone gives a simple analogy or explanation is to how this is stored then finding a solution for this problem becomes much easier.
sqlite stores its data in files in a folder on your filesystem, using its own system of storage.
postgres will do a similar thing, but in a different folder, using a different system.
You will generally never touch these folders. You don't need to know where they are or how the dbms (database management system, eg sqlite or postgres) stores the data. All your interaction with your dbms will be done either via the terminal, or the dmbs's shell client (which you launch in the terminal aka the shell), or via a desktop client, or via your rails app's own connection with the dbms.
When you make a new rails project you need to create the database it will use. If you switch to using a different dbms then you will need to create a new database in that dbms for your app to use. Google how to do this.
If you have data in one dbms and you want to bring it into a different dbms then you will need to export it from the first dbms and import it into the second dbms. Google how to do this.
rake db:migrate will run any migrations which haven't been run in your current database (ie the one in your database.yml). Rails creates a table in your database to store which migrations have been run already: this is how it keeps track. It will fail if you haven't created the database yet.
This question already has answers here:
How to export table as CSV with headings on Postgresql?
(14 answers)
Closed 9 years ago.
I am trying to export a CSV file from Heroku's PostGresql database to import it into a MongoDB outside of Heroku. Does anyone know of any good way of exporting a CSV file from directly from the Heroku website?
The question is asking how to export a CSV file using Heroku's web interface, not the command line interface.
You can export a csv of a single table using dataclips: https://dataclips.heroku.com
To export the entire database like this you would need to do this one table at a time
This question already has answers here:
Portable Ruby on Rails environment
(6 answers)
Closed 7 years ago.
Is there any way to run a RoR app as a 'portbale app'?
For instance, can you put an app including the ruby on rails stack, web server et all, on a stick and then just run it on a windows machine? Without installing?
There was project called Instant Rails that provided this more or less, but it's not maintained. (http://rubyforge.org/projects/instantrails/)
Also, there is RubyStack from Bitnami (http://bitnami.org/stack/rubystack#nativeInstaller) but it needs to be installed (I can go with that, but rather not).
So, the question is, can Ruby on Rails, including a specific app, be made to run on any computer (well, let's start with Win) from a stick, CD or DVD, without having to install anything first?
I think this is what you are looking for:
http://www.erikveen.dds.nl/distributingrubyapplications/rails.html
This tutorial walks you thru the entire process of creating a self-containing windows app that bundles your rails application inside it.