I want to try the Arbre gem for rails. There is an example on this page: https://github.com/activeadmin/arbre/blob/master/README.md
Where must I paste the next code?
html = Arbre::Context.new do
h2 "Why is Arbre awesome?"
ul do
li "The DOM is implemented in ruby"
li "You can create object oriented views"
li "Templates suck"
end
end
I want to try the code above, but I don't know where I must paste it. Which file? Which method? I pasted the code into my controller, but it doesn't work.
In the example you pasted, the
htmlvariable now holds the html for your page.You can render it in the controller like this:
app/controllers/whatever_controller.rb
Also, it isn't well documented on the Github page, but digging through the source, it appears you can also use
abretemplates in place of regular erb views like so (notice the.arbfile extension):app/views/whatever/show.html.arb
That way, your controller could look like this:
app/controllers/whatever_controller.rb