I am a total newbie to ruby rails, and i went through the basic tutorial and a sample blogging application with postgresql backend, in the link. Although i kind of got the gist of it, i really didnt understand how the application accesses the postgresql at the backend and also didnt understand the application flow and few keywords which occur in the controller and view files, for example the below line which appears in the index.html.erb file.
<td><%= link_to 'Edit', edit_post_path(post) %></td>
For instance, i didnt understand the edit_post_path(post) keyword. Can someone please point me to a good source for understanding the very basics of rails?
Welcome to the Rails developer community!
Resources:
MVC
The core principle of Rails is it's a full-stack MVC framework
MVC = Model - View - Controller
If you can learn how this works, it will be the foundation knowledge you need to make good progress. Rails does not work like "standard" websites -- it's a full blown application development framework which works with the MVC principle:
Data
The "flow" of data through an MVC application centers on the user
The user requests a page (by typing / clicking on a Rails route), the request is sent to a controller, which may pull data from the model. The data is kept in an external database (can be MYSQL / PGSQL / anything), and works by connecting through a gem
Your job as a developer is to make sure the user is presented with the correct data & options at the right time
Question
<%= link_to 'Edit', edit_post_path(post) %>
This is a link to the edit
post
path, which will be defined in your config/routes.rb
file. This path will load up this file / method:
#app/controllers/posts_controller.rb
def edit
#your code
end
This will then render a particular view file for your users to use. There's a lot more to explain other than this, but I hope this gives you the help you need
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With