A way to convert view commands to its corresponding html(like irb or ruby script/console)
Is there any way to see view code converted to html other than starting p开发者_运维百科roject and view the page source? In Rails development environment, we can use code and see what it returns, but it would have been nice if we were able to do something like this.
<< @user = User.all.map { |user| [user.name, user.id] }
=> [["Patrick", 1], ["Greg", 2]]
<< select_tag "user", @user, {}, :tab_index => "5"
=> "<select id=\"user\" name=\"user\" tab_index=\"5\"><option value=\"1\">Patrick</option>
<option value=\"2\">Greg</option>"
Is this possible?
On Rails 3, you can access these helpers via helper
.
$ rails console
>> helper.select_tag "user"
=> "<select id=\"user\" name=\"user\"></select>"
>> helper.submit_tag "goodbye"
=> "<input name=\"commit\" type=\"submit\" value=\"goodbye\" />"
精彩评论