First off, I'm going to second Terry's recommendation that you work through a full book on rails. While the beginner tutorials are great for giving you an overview of a particular task, you're not going to get a firm grasp of the big picture in rails just from tutorials. A book will fill in a lot of the gaps for you.
prtscr wrote:
1) All the tutorials show who you do things in subdirectorys (for
example: localhost/myproject/blog). How do I do to get things to
happend in the root of my project?
This is called routing. The root of your project is called the default route. Take a look in config/routes.rb, and in particular, at the line which includes
map.connect '', [...]
This is where you would specify what you want your default controller (and action) to be. There are a number of good reference to routing online, if you google for it.
2) What are the difference between the directories \app\views and
\public , how do you use them in conjunction with each other?
your public directory stores all of the static files used by your railsapp. This includes your images, stylesheets, javascripts, and so forth. That "Welcome aboard" page you get when you first load rails? That's also a static file -- index.html. These are all things which the web server can hand off directly, without having to broker them through ruby.
your app/views are rails template files. These provide the "view" or layout of the pages which rails generates.
3) How do you separate the frontend from the backend? Let's say that
you have a blog with posts and comments. Then you want yourself to be
able to CURD both posts and comments and everyone else just be able to
add comments.
Instead of thinking of this as "frontend" versus "backend", think of it as access controls. You have visitors who access your site. You want to some of those visitors to have access or permission to certain actions on your site.
First you need a way of determing who a visitor is ("authentication"). This is usually done through some sort of login widget. If you google for "rails +login" or "rails +authentication" you'll find a number of options, including tutorials on how to write your own.
Second, you need to decide on what roles you want to have. This could be as simple as "admin" and everyone else.
You need a way to assign those roles to user. If your needs are very simple, you could update your users model to include a "role" column. Alternatively, you could have a separate "roles" model and then a join table which assigns roles to users.
Third, you need to restrict or grant access to your controllers/actions based on the role of the current user. This could be done through a before_filter which checks current_user.role before it loads the requested controller/action. If the check fails, then the user will be redirected elsewhere.
This sort of thing is covered in the "Rails Recipes" pdf from the Pragmatic Programmers website. You will also find a number of tutorials and plugins which will show you different ways of accomplishing it. This can get to be a fairly complicated topic, and is well worth reading up on
I hope that helps get you started!
~gwendy