Hello guys,

I'm dealing with some issue about best practice of how to use Rails
code.
So, what's the best way to write the following lines that basicaly does
the same thing?

Let's say we have a link that needs to be a button with some parameters
(theme, size and icon)

1. = link_to "Login", "#", class: "button", data: {theme: "green", size:
"large", icon: "small-arrow"}
vs.
2. = link_to "Login", "#", class: :button, data: {theme: :green, size:
:large, icon: "small-arrow"}

both of them should generate something like this
<a class="button" data-theme="green" data-size="large"
data-icon="small-arrow">Login</a>


Personaly I prefer 1. because when it comes to maintanability is easier:
let's say that we have to add a second class "login" to this link/button
and to change the theme to "dark-red"

1.
- adding the class: just click after the "n" letter after the word
"button", hit a space and write the second class "login"
- changing the theme: double click on "green" word and write "dark-red"

2.
- adding the class: delete the ":" character, select the word "button",
wrap it in quotes, add a space and after that the class
- changing the theme: select ":green", add quotes and write the
"dark-red" theme

I find the first version to be more faster to perform than the second
one -> improves mentainability


Other points could be:
- using ":word" notation doesn't work with spaces and dashes (other
characters), but the "quoted string" notation works
- keeping a single way of coding (the one that handles all the cases) ->
more as a standard


So, what do you think? How do you code when you have something like
this?
I would like some opinions about this from some experts in coding Rails.

Thank you very much!

-- 
Posted via http://www.ruby-forum.com/.