0

Im trying to apply friendlyId gem onto my rails app.

When I have done

1 : installing gem, 2 : and this

bin/rails g friendly_id
  create  db/migrate/20150220082838_create_friendly_id_slugs.rb
  create  config/initializers/friendly_id.rb

bin/rake db:migrate

db:migrate runs okay but when I go rails s, I get the following message

Migrations are pending. To resolve this issue, run:

bin/rake db:migrate RAILS_ENV=development

  include FriendlyId
  friendly_id :account

Then when I do bin/rake db:migrate RAILS_ENV=development, console returns this error

PG::DuplicateTable: ERROR:  relation "friendly_id_slugs" already exists

I've tried dropping db but it just gives more more problems to solve(since I already have users data in my development.)

and when I google it, same issues reported in github page is already been solved by the bug fix and it won't give me a hint for me to solve it..

How could I get this to work properly??? Thank you for your time.

Hirohito Yamada
  • 387
  • 1
  • 4
  • 17
  • 2
    Follow all the instructions that has been give on the github, You have to add the slug field in the database and then you have to define the fields to create the slugs for the user record. – Bharat soni Mar 17 '16 at 08:53
  • You are trying to use a non-slugged version as a parameter as well. You should be using something like `localhost:3000/users/hirohito_yamada` otherwise it would have to be URL encoded: `localhost:3000/users/Hirohito%20Yamada` – max Mar 17 '16 at 10:00
  • ive tried but got stuck... updated my info, would you be able to take a look?? thank you so much. – Hirohito Yamada Mar 18 '16 at 07:43

1 Answers1

0

Following solved my problem...!

bundle exec rake db:reset
Hirohito Yamada
  • 387
  • 1
  • 4
  • 17