I'm too late to the party, but instead of saving the URL twice and adding the id to the slog, you could use ActiveRecord's [to_param method](http://apidock.com/rails/ActiveRecord/Base/to_param):

```ruby
def to_param
  "#{id}-#{slug}"
end

def self.create_with_last_accesses(params)
  shortened_url = new encoded_url: params[:encoded_url], last_accessed: Time.now
  shortened_url.slug = SlugMaker.slug("#{params[:dashboard_name]} #{params[:graph_title]}")
  shortened_url.save!
  shortened_url
end
```

In the controller, you can then simply use `widget_url(shortened_url)` which will automatically call `to_param` for you.