0

I have the following recipe for Chef:

def prestashop_deployDatabase (username)
    sql_path = '/tmp/prestashop_create_tables.sql'

    template sql_path do
        source "prestashop152.sql.erb"
        owner "root"
        group node['mysql']['root_group']
        mode "0600"
        variables(
            :username => #{username}
        )
        action :create
    end
end

For some reason; it cannot understand the 'username' argument i'm passing.

PS: I'm a Ruby n00b.

2 Answers 2

3

#{username} is a comment in ruby. You should write "#{username}", or better in this case, just username.

Sign up to request clarification or add additional context in comments.

1 Comment

Not entirely equivalent, username.to_s in case you get weird errors.
2

In ruby:

  • # in code starts a one-line comment
  • #{} in a string starts interpolation - everything in the braces will be interpreted as ruby code.

Since you're using # in code here, it comments out the rest of the line {username}, so in effect your code says this:

variables(
  :username =>
)

which will give you a syntax error.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.