Search code examples
ruby-on-railsmeta-tags

After installing meta-tags gem for rails, how do I edit my m/v/c/ files to use it?


I have successfully installed the meta-tags gem for Rails and verified it.

Now, I am not sure how to modify my model/view/controller files to make use of the meta-tags gem. Specifically, I have an app with a Product model and 2 static Pages. I am trying to take strings from the Product db and dynamically populate the meta tags for Product view pages with those values. Then, I'd like to also set meta tags for the 2 static Pages.

Specifically, after adding

<%= display_meta_tags site: 'sitename' %>

I get the following error in localhost

undefined method `display_meta_tags'

I'm not sure where to set the meta tags and exactly what syntax to use in those files. I guessed it was the controller file for setting variables, but various trials of this haven't resulted in fixing the issue. I may, however, not have the correct syntax.

I tried searching, reading the meta-tags usage section, and reading this question, but neither had enough detail as far as where to put the various statements into my own m/v/c files. In addition, other blog posts show people using various workarounds to declare their variables more efficiently and I'm not sure which consistent set up to use.

I'm new to Rails, so apologies if I have overlooked something obvious. Thanks!


Solution

  • Resolved. Turns out I needed to restart my rails server. I figured this out by searching things related to 'undefined gem methods' and got this question --> Using Gems with Ruby On Rails: Undefined method?