Skip to content

Instantly share code, notes, and snippets.

@adriand adriand/
Created Oct 14, 2014

What would you like to do?
Tenon FAQ

Q: I changed a SASS variable but the change is not reflected in Tenon. I even restarted my app and there's no change!

A: Delete the entire tmp/cache folder and try again

Q: How do I install the config file, main menu nav, and custom colours file into my app?

A: bundle exec rails generate tenon:install

Q: I got the error "Could not infer a decorator for MyModel" but the decorator is there!

Restart your app, and consider adding app/decorators to your autoload paths. Also, that wasn't a question.

Q: The feature specs take a really long time to run, is there a way to just run the unit tests?

You can run rake fastspec to run all the specs except feature specs. If you're committing to master you need to run everything though.

Q. How do I tell the scaffold generator to add an asset attachment to my model?

Include this in your generation command: name_of_thing:asset. For example: rails generate tenon:scaffold item title:string photo:asset.

Q. How do I refer to an attached asset in a view?

Assuming product has_asset photo, like this:

Q. None of the view helpers work in ActionMailer views, like link_to, url_for, and so on.

For a dynamic URL like course_url, you want either main_app.course_url or tenon.course_url - probably tenon.course_url.

Q. How do I keep things like padding and margins consistent?

There are a growing number of Tenon SCSS variable that you should (re-)use. Like $tn-margin and $tn-padding for standard (currently 16px) padding and margins. $tn-header-height (currently 50px). There are also a bunch of $tn-z-x variables for z-indexes. Using these variables should make it easier to change Tenon styling globally in the future.

Q. How do I use has_history for revision tracking?

Tenon has a revision history feature called has_history and it comes pre-installed on Pages, Posts, Events, and Galleries. It also will be automatically included on anything you scaffold (although there is no UI for it for _small scaffolds).

has_history captures form data to create a snapshot of an object at a given time. One of the limitations of that approach is that it can only save information about child objects that are handled via accepts_nested_attributes_for.

Another really important thing to note is that you need to manually specify which child attributes you want it to save, and that Tenon Content is built out of accepts_nested_attributes. That means if you don’t manually specify it in the model your drafts will not actually save your client’s content, and you will get yelled at and it will be terrible.

Consider the following model

class Event
  tenon_content :description

This will not actually save history for the description. However, making it save the description is real easy:

class Event
  has_history includes: [:description_tenon_content_rows]
  tenon_content :description

Similarly, you can also pass except: and only: options to has_history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.