I'm still learning rails but want to be sure I'm heading in the right direction. For several of my models I want to let a list of users know that updates have been made when a new record is created for example. I'd like to tie this to an email and in-app notification(doesn't need to be AJAX), next page refresh is fine.
I've been reading up on observers some and I think that's what I want but they seem somewhat controversial based on the blogs I've read. Services like Pusher seem to be overkill for my needs.
Would this be a good solution for this scenario? Also, can anyone point me to some example code that I could emulate?
Thanks!
Check out Rails Cast if you are trying to learn. Best free code base I have seen. Also check out this book another great learning tool. Agile Web Development with Rails (2nd edition).There might be some newer ones out but I have not checked.
Related
I have a really stupid question in my mind.
I have used Wordpress to create a website for long time, but I dont want to use it anymore. And now I am looking for little bit different approach. Otherwise, I am quite new in Ruby on Rails. I have read some books and I am not feeling in this matter so confident. So, here is the deal:
My friend asked me to create a simple website for his company. He wants only super simple static website which will contains these pages:
Home
Products
Contact
Each page will contain simple information and there is no need to implement contact forms and other basic functionalities. I also want to deploy this app on Heroku, because he has not a lot of money and we are looking for free hosting. Moreover, I think that the best approach in this matter will be some kind of CMS which will help him to edit the website.
The overview of final solution:
Static webpages with simple CMS
Using twitter bootstrap for basic layout
Deploy on Heroku
I appreciate every contribution in this matter.
Thank you
Everything you have said suggests that you should stick with WordPress. It's perfectly capable of presenting a non-blog static website (use Pages instead of Posts) and there are some excellent themes available. WP has, over the years really become a CMS that's also good for blogging. There are other tools like Drupal that may be appropriate.
I set up a WP site with almost exactly the same goals for some very non-technical people; with a little training they eventually learned how to manage the site, upload images, add content, grant permissions to others, and do a lot of other pretty cool stuff. I have been using Rails since 2007, but for that case, it was not the right solution.
Rails is a very (very!) sophisticated web development environment used to build complex and scalable dynamic websites. With power comes a level of complexity several orders of magnitude higher than WordPress. Even if you use refinerycms you still need to do a lot of complicated setup, and need to know a lot of stuff. Even if you're using Heroku and following a RailsCast like the one for refinerycms, you'll undoubtedly hit some wall where you really need to understand more ... Rails is alluring this way -- seems simple.
If you are using this a reason to learn Rails, and are willing to invest some time, then by all means go for it. But if you want a simple solution, it's not the way. Learning Rails is like learning to fly a plane, but harder.
For static pages with rails, you can use High Voltage gem. You can find the detailed usage of this gem in this blog post . Once you create the pages, then you can easily deploy your app as like normal rails app in the heroku.
I have a best practice question. I have two classes, company and category. They have a many-to-many relationship. When clicking a category I shall go to a page showing all companies with the chosen category. Pretty straight forward.
My question is:
Should I list all the companies on the companies/index.html.erb after filtering the companies in the controller?
or
Should I list all the companies on the categories/show.html.erb page?
or
Should I do a completely new page, since it doesn't really fit into any of the two above?
Do you generally make a new page when your goal doesn't fit the scaffold made pages or do you use them quite freely?
I am working/learning alone with rails, so there are a lot of best practice questions popping up all the time.
Cheers Carl
A scaffold is a starting point, so you should always consider what you need in your web application.
In you case, I think all examples are fine, but again, it's really up to you.
If you are just learning Rails, stick to as many conventions as possible. Scaffolding is one of the ways Rails can help you get things started when you don't know how all of the pieces work together.
But like Oscar said, ultimately you must decide what your application will need.
The Ruby on Rails platform comes with many principles such as DRY etc.
The main part is the MVC architecture, the thing scaffolding does is let you see how this MVC is used correctly by a Model, View and Controller generation.
When you learn how this works you will be able to answer your own question, I could write my thoughts down but it is key for a Rails developer to understand the MVC structure so my suggestion is to read:
http://betterexplained.com/articles/intermediate-rails-understanding-models-views-and-controllers/
have fun
I'm curious to learn Ruby and Ruby on Rails. I have previous experience with PHP and some basic C/Objective C and Java.
I have done a couple of 'Get started with Rails' tutorials and want to try do create a complete site now. I do have some questions.
Is the entire website an app? I mean, sure, the simple 'blog-with-comments' examples fit in a single app. But what if you want more? Say, a forum, a blog, community, shop, task manager and so on (only random examples here... :) ).
Should I split these things into different 'apps' or not? I would still need them to communicate with each other and share user data and so on...
Any ideas?
Regards
Linus
In general, your core competency as a rails app -- that which you provide the most value for your users. You can then supplement from there, so your support section might be GetSatisfaction and live on support.yourdomain.com.
Your online shop could be a link to your shopify page at shop.yourdomain.com, etc.
I wanted to make a web site with the following basic features- (1)User registration for buyers and sellers. (2)profile pages (3)A buyer should be able to post work and should get profile links of the corresponding seller who has expertise in that work.
As time progresses i would want to add more features to the site.The freelancer sites where user can post jobs and get bids is the best example of the work.
(1)I want my code to be maintainable as i woud be adding features later on. (2)It should be quick to develop. (3)Resources should be available(not the entire thing, atleast in bits and pieces) for the above requirements and should not be tough to find for future enhancements. (4)Design should be decoupled from the buisness logic as i would outsource the design work.
I was thinking of Ruby on Rails for this work as i have experience in the MVC model and RoR looks cool.I am from the mobility domain so i don't know whether RoR will suit my work
Would RoR suit this purpose.If yes where can i find the resources to the above mentioned requirements.
Thanks
Ruby on Rails would be ideal for this type of website.
Check out some of these resources for info on how to use Ruby on Rails:
http://guides.rubyonrails.org/
http://railscasts.com/
http://www.railsforum.com/
I noticed you are already aware of TeachMeToCode, but there is a tag there for all the Rails 3 tutorials, with some blog tutorials and what looks like the beginning of a series on how to build a del.icio.us clone. Since they are in Rails 3, they would be well worth checking out:
http://teachmetocode.com/screencasts/tag/rails-3/
One of the best tutorials:
http://railsforzombies.org
It will let you have your own point of view quickly.
It depends on with which languages you have experience. Any good MVC framework will do the job just fine but if you like Ruby syntax RoR is definitely a good framework to develop this kind of application.
I'm desperate. I've read and tried many things with rails. The problem isn't that "big", it is just that I'm still getting used to the convention over conf world. Lack of examples, too.
I just want to be able to have a site where you have roles (think admin, normal user, etc) and each of these can view,say, posts, articles. However, the admin obviously has access to update/delete posts,articles. Users only post, things like that.
I can create the authentications, sessions, and all. But I don't know how to present (or refactor) code. Where does the code for the admin go? views?, what about for users?
Would I need to create controllers specifically for admins, and users, others, in order to display the same model objects (articles, posts) that I'll be dealing with? including views?
Thanks
There's a free Railscast that may help you with this called "Authorization with CanCan".
If you feel like parting with some money, Rails 3 in Action also covers this sort of thing in Chapters 6 and 7.
First, watch this screencast: Where administration goes.
Second, watch this one: Restricting Access.
Then this one: Super Simple Authentication.
This should clear up your confusion and help you wrap your mind around "The Rails Way" of doing authentication and administration.
Once your immediate crisis is over, I would STRONGLY recommend you pick up a copy of "Beginning Rails 3". The kind of frustration you're experiencing is normal: when you come from the world of basic HTML plus scripting (javascript and php most likely) it's really hard to "get" the big idea that a framework imposes on your design.
Beginning Rails 3 takes about 2-3 days to work completely through, front to back. When you're done you'll TRULY understand Rails and your work will feel like FUN, not frustration. It's really, really, really, really worth it to take the time to read the book. 2-3 days with the book will save you 2-3 months of mediocre coding and learning by trial and error.
There are lots of examples available. One of the best sources of information is Railscasts. You will find many screencasts on authentication (including the most recent (#250), as chance would have it). You will also find them on authorization, which is the role-based mechanism you describe.
Here's a pretty thorough comparison of many authorization plugins: http://steffenbartsch.com/blog/2008/08/rails-authorization-plugins/
I would also look into cancan (railscast), which is newer than that list and highly regarded.