Method.to_proc
Most people don’t know about ruby’s builtin Method.to_proc. Sure, we all know Rails’ symbol.to_proc:
1
|
|
But Method.to_proc is also quite handy. Let me show you.
Pretty awesome right?
Rails developer/teacher, with a special interest in emberjs
Most people don’t know about ruby’s builtin Method.to_proc. Sure, we all know Rails’ symbol.to_proc:
1
|
|
But Method.to_proc is also quite handy. Let me show you.
Pretty awesome right?
Back in the days with rails 2 you could easily create a handler for liquid and have access to the instance variables you’ve created in your controller. However, the creators of liquid didn’t like this approach and so when Rails 3 came out the functionality didn’t get upgraded.
I needed this functionality today for a cms I’m working on so I took some time and headaches to figure this one out.
1
|
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
1 2 3 |
|
Now you can create files like posts/index.html.liquid. In our case, we have our views in the database so we can render different views for different websites. The book Crafting Rails Applications has an extraordinary chapter that shows you how put views in your database, worth every penny.
So it has been a while, but I’m back. I was thinking of creating a new blog site from scratch, but then I found out about octopress. I quickly decided it was time to get my hands dirty and setup this new site.
Mostly tech posts about rails, sproutcore, setup configurations etc.
I certainly hope so? Otherwise this site will just be a list of reminders for me to do some awesome stuff :)
Hope to see you here around, and I’ll try not to let you down