Search code examples
ruby-on-railsrubyyamlslim-lang

connecting yml to html.slim


There are two html.slim files as:

client view:

= f.input :name,
        required: true,
        :wrapper => :input_wrapper 

company view:

= f.input :name,
        required: true,
        :wrapper => :input_wrapper 

there is shared yml file that defines the displayed values as:

 simple_form:
        labels:
            defaults:
                name: some value

How can I define different name values for the company and the client, ideally without chenging the view? Moreover, how is the yml file linked to the slim file? For example in the routes files it is specified the url and the corresponding view file, how does that work between yml and html.slim files?


Solution

  • In the documentation you will find the following:

    simple_form_for @admin_user, as: :some_user will look into the yml file under some_user instead of admin_user so the yml file will look like this:

    en:
      simple_form:
        labels:
            admin_user:
                name: Admin Name
            some_user:
                name: Some user name
    

    So in your simple_form you can add as: :client and as: :company and add those 2 to the yml file.