On 23-06-2012 20:32, Jurgen Raedts wrote:
I've done a few tutorials and small simple apps and would now like to
make a somewhat larger application at my college to take student
assesments. I just can't figure out where some application logic
should go... Maybe someone could give me some pointers?
The business logic belongs in the model. You should keep your
controllers to a minimum. Some people do a mix, but a I personally, and
I believe the majority, put the business logic in the model. The role of
the controller is to act as a broker between the view and the model. It
gets the data from the model and hands it over to the view.
If you do a search on Google you should find quite a lot of useful
information, and I guess your question answered in a few different
places. But read the guides in http://guides.rubyonrails.org
and go for
the online book Rails Tutorial that can be read onhttp://ruby.railstutorial.org/ruby-on-rails-tutorial-book,
or if you
prefer to read offline, you can purchase the pdf.
This is what I want to do: a student or teacher logs in on the site. A
student can take an assesment of 70 questions (always the same 70
questions) or will see the results of his previous assesment. A
teacher will see the results of all take assesments by the students.
The application will process results based on the answers when needed
and generate textual advise on student attitudes (texts are known in
advance an won't change themselves). Authentication will be done on
active directory through Devise.
I think I need 2 models: users (has_many assesments) and assesments
(belongs_to users). I'm not sure about the controllers though. Should
I put all logic in a user and assesment controller or is it useful or
better to put logic in seperate controllers (show_own_results,
show_all_results, calculate_result, etc) or make a seperate controller
called results and put my methods in there?
As I mentioned above you should place the logic in the model. You should
start with a basic authentication, and then add roles to your users so
that you can control what they can or cannot see. I am not that
experienced with Devise, but I know if plays well with CanCan, which is
an authorization plugin that will let you control who has access to what
and who doesn't. In your case you could have two roles: student and
teacher. users with student role can take assessments and view the
results. The teacher role can see the results and generate reports on
that (or textual advise as you call it)
Sorry if this is a stupid question, I've just started to learn and
have been breaking my head on this for days. I've changed my mind so
many times about what I should do best but I don't seem to find the
right solution for the logical way to do this in Rails. This is my
first framework development btw, I'm not used to web programming.
Don't worry. Just go through the tutorial found inhttp://guides.rubyonrails.org
and then read the Rails Tutorial book.
That should clear your doubts.
If after reading those references you still have questions, do a search
on Google first, as you will get your answers faster. I am actually a
long time member of this mailing list, and it has been a while since I
posted any question here. I use mainly Google, as Rails is one of the
frameworks with extensive documentation and online help. But, if you
don't find your answers than send your questions here and you should be
able to get some help. But as I said before, you may find your answers
faster from a Google search.
Hope my reply to your questions was useful to you.
Good luck with your Ruby on Rails learning quest.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to email@example.com.
To unsubscribe from this group, send email to firstname.lastname@example.org.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.