understanding ruby on rails project [closed] - ruby-on-rails

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
For me to understand the rails project is not enough to see the model or controller diagrams and how many attributes and actions they're having. I understand more if I know where actions are initialized and how they ended. To describe my thoughts more specifically I'll show some example. Let's take nice open project Railscasts. I chose the Comment controller because it nested inside others controllers then it's a little harder to understand how this works. Here's my picture that helps me to understand it.
This isn't well composed diagram but fine for me. On this picture you can see where action is started and what's the reaction on action. The action edit initiates in views/episodes/show.html.erb, comes to controller's action edit, after that shows the edit form, then go to update action and finally go back to show.html.erb. From this picture you can see that a lot of actions initiate in show.html.erb that belongs to episode controller and makes harder to understand how works the comments controller. Now you can easy find place where is action comes.
Here is my questions:
Do you think this idea is useful for you, can make your developer's life easier ?
Do you know some tool that can make such kind of pictures automatically ?

This is quite argumentative, but answering to question 1 :), I have to say that your diagram has a huge noise/signal ratio.
Your diagram only talks me about routing which honestly in a mid-sized scenario is not so complicated to need a diagram. And does it pushing a lot of noise (why I need to see the class of a destroy link?)
Rails is a lot about conventions and to be honest I don't feel the routing mechanism to be so complicated to need a diagram. Just my 2 cents.
To Question 2: I often find RubyMine model diagram to be quite useful, but I think you need a more 'dynamic' view of the project.

Related

What most comfortable and useful: ActiveAdmin or Rails Admin? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
So, what most comfortable and useful for developer? A similar question was already 4 years ago, and many things could change.
http://activeadmin.info/
https://github.com/sferik/rails_admin
or maybe Typus https://github.com/typus/typus???
Disclaimer: this is only opinion. This kind of question can have no 'correct' answer.
I use Rails Admin a lot on my current main project. It has advantages and disadvantages.
Advantages:
It handles things like nested forms for ActiveRecord relationships out of the box.
Disadvantages:
Adding features or custom behaviour is quite difficult and documentation is over-complex and fragmented.
Putting the DSL for CMS behaviour in the models is not great for code separation.
The default style is a little outdated.
The DSL itself is over-complex, badly documented and prone to code bloat and duplication.
The use of PJAX for page updates can complicate any JS you wish to add to the page. (If you're not careful your code will be run multiple times, or not at all, for a single page.)
The default mechanism for saving content items is incompatible with a database that uses referential integrity. This is a very bad thing. (I ended up patching this code.)
I haven't used ActiveAdmin as much, but when I have I noticed the following things:
Out-of-the-box, you have to roll more of your own features when it comes to things like nested forms for relationships. (This may have changed over time.)
It looks lovely.
The DSL is neatly separated from the model code and feels more logical.
Adding your own features is a lot easier with less code.
Adding JS is pretty trivial.
I don't know if Active Admin is better for referential integrity, but if this interests you let me know in comments and I'll set up a couple of trial projects to show you what I mean.

When to use helper methods and private methods in Rails? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have been hearing that the controller should be as concise as possible. So, I try to keep most of the processing work in the helper for the corresponding controller. But, I am little confused regarding whether I should instead use private controller methods or helper methods.
I am using helper methods only for processing and returning values. They have no other usage for now. They are not called from views.
That's a bad idea in general. Helper methods shouldn't be used except for specific convert-something-into-string stuff (basically, should be used only in views).
For anything else, you should use service objects or something similar, basically, PORO (plain old ruby objects)
In controllers you want to handle authentication and render the right thing, you don't want to deal with anything else otherwise they become too complex.
You might want to check these books to improve knowledge about this topic:
Growing Rails applications which is a really good book on how to avoid putting code in wrong places and how to keep codebase maintenable on the long term
POODR which is a Ruby guide on how to write good Object-Oriented code, it's a must for any developer and will help you understand why using an helper it's a bad idea
Usually, a Helper is called in a template or a view.
If you want to keep your controller DRY, use functions in your models or in services (read this good article about services by Ben Lewis)

Looking for a Rails plugin for modular wiki functionality [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
There are a few plugins that implement a traditional wiki (collection of stand-alone wiki pages in a flat namespace), including irwi and wiki_column. That's not what I want.
What I want is something modular, so I can add a wiki panel on any random page of my website, or have fields in several different models be "wikified" (editable by all with version history). In other words, I want embeddable wiki objects rather than a full-page wiki, and I want the wiki content blocks to be anonymous rather than named in a unified flat namespace, or associable with specific objects.
Is there anything like that?
To wikify content is rather easy, so here some thoughts to it:
Have a look at the Railscast: Markdown with Redcarpet which explains how to wikify (that means style) content as HTML. That is one of the things you have to have to wikify pages. It is rather simple, and works like a charm.
Second, how will you link to "wiki content" without a name? For me, wiki is at least some content that is linked ...
To get a history, you should link your model object to versions of model. The Railscast #177 implements a wiki with versioning, perhaps that gives you enough hints to do it.
To add "a wiki panel" means then, that you have a (versioned) model WikiPanel, that may then used by other models. Hope my hints give you a starting point (even if it comes 20 months too late ...).
You could check out AdvaCMS, which features a wiki. AdvaCMS is built with Rails Engines (e.g. plugins). Check it out at http://adva-cms.org/wiki

Best practice to start with the development of a web app [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
We (a group of 4 students) are planning to create a web-app on Ruby on Rails. I have done some web app projects in the past and one thing I have learned is the initial time devoted to design the app, which was very less, I just start coding with some basic things in my mind.
So, this time, I don't want to do the same mistake and want to plan the app (high level design). But again, sometimes I feel it might be an overkill for a student project which might span for 6 months.
So, what should be the best approach in this case?
My reqs are:
A plan which guides us through the development.
Should the plan be a text doc, a block diagram or what?
Should be clean, crisp and concise.
Would be great if you point me to some sample doc, template etc. Which is not an overkill but effective.
Start making a clone for stackoverflow. Dont go for a full deep functionality for initial stage.
Divide the whole functionality in 4-5 different phases.
Decide your phases.
You can use basecamphq(30 days free) or Fogbugz for planing, to-dos and lighthouse for bug tracking.
EDIT
Just think about the basic minimal functionality SO has:--
Sign-up. (Normal + open-id)
Ask a question, answer a question
Comments on question and answer
Votes on question and answer
tag a question
Question stats like question views, Unanswered question etc
Points
Badges etc
Make a list and divide them in various phases. Don't try to make exact thing in one go. Just start from basic things.
Like for the first phase.
Sign up
Ask question, with tags
answer a question
comments on them
Basic profile page.
For next phase:--
Add ajax for comments (Good for learning ajax)
Votes, Not points
Add things like Unanswered questions. (initial dont try to find the logic how SO is listing unanswered questions, Just do something like unanswered questions means question having no answer.)
Question views
then next phase and next phase. and finally you have a clone. :-)
Ask Jeff to review it. (Kidding)

Best practice for determining necessary controllers for simple ASP.NET MVC site? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm playing with the ASP.NET MVC Framework, trying to create a simple site.
My model is essentially:
-Questions
-Answers
-Categories
Since each Question must belong to a Category and each Answer must belong to a question - is it correct to split 'Category' into it's own controller?
What would be incorrect about creating a controller path of /Question/Category/List?
Also, if I wanted to create a search - do I then create a controller called 'Search' and use like so: /Search/Question/, /Search/Answer/? Or do I use '/Question/Search/'?
Thank you in advance for any insight.
Below is a read regarding grouping controllers
Grouping Conrollers
The above is not directly related to your question but may be useful.
Now regarding your question, I'll take it this way.. (This is just one way)..
My initial take on this...
-for Questions and Category
/Question/Ask
/Question/Edit/{id}
/Question/List
/Question/Search/{criteria}
/Category/Create
/Category/Edit/{id}
/Category/List
-for answer
/Question/Answer/{questionid}
/Question/Answer/Search/
/Question/Answer/List/Group/Question
The other approach is to separate the controller with respect to Admin and Visitor functionality. Put all the admin logic like create/update/ in one controller and split the remaining logic into other controllers. There may be +/- argument to this. But's that's an individuated opinion.
Note:
Category can exist independent of the question
A question is associated with one or more category
An answer belongs to a question and cannot exist independently.
*** The example came out of top of my head and may not be the best practice but may just give some points to ponder. :). Feel free to apply your ideas.

Resources