How do I run multiple lines of Ruby in html.erb file

If you need extra functions in your view, you normally declare those inside a helper. For each controller, if there is a helper it is automatically loaded. For instance, if you have a PeopleController, in the app/helpers folder, there should be a people_helper.rb, and it should look like this module PeopleHelper def name #do something … Read more

How to create fixtures (for a Devise user) as a yml.erb in rails (4.1.5)?

You should pass the password in plain text too. I am sure there is a User model validation errors preventing your fixture users from being created. Here’s an example from my users fixture which works: tom: first_name: Tom last_name: Test email: [email protected] password: 123greetings encrypted_password: <%= User.new.send(:password_digest, ‘123greetings’) %> If it still fails, please check … Read more

Including one erb file into another

ERB templates can be nested by evaluating the sub-template from within <%= %> of the main template. <%= ERB.new(sub_template_content).result(binding) %> For example: require “erb” class Page def initialize title, color @title = title @color = color end def render path content = File.read(File.expand_path(path)) t = ERB.new(content) t.result(binding) end end page = Page.new(“Home”, “#CCCCCC”) puts page.render(“home.html.erb”) … Read more

Leaflet Marker not found production env

This is a known bug in Leaflet, the root issue is that Leaflet’s icon image location is been wrongly referenced during bundling. You can verify that this is your issue, buy validating this parameter (in run time): L.Icon.Default.prototype._getIconUrl(). The correct value should be <some_directory>/leaflet/dist/images/. However if this bug is happening to you, it’s value is: … Read more

How do I execute ruby template files (ERB) without a web server from command line?

You should have everything you need in your ruby/bin directory. On my (WinXP, Ruby 1.8.6) system, I have ruby/bin/erb.bat erb.bat [switches] [inputfile] -x print ruby script -n print ruby script with line number -v enable verbose mode -d set $DEBUG to true -r [library] load a library -K [kcode] specify KANJI code-set -S [safe_level] set … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)