Using Storytime on a site that already uses FriendlyID for pretty urls
Closed this issue · 7 comments
I added the storytime gem and went through the Guided setup process. I can navigate directly to individual blog posts, e.g. http://localhost:3000/news/posts/test-post
but the blog/index http://localhost:3000/news/blog and http://localhost:3000/news fails, redirecting to the root page.
here is the log:
Started GET "/news" for ::1 at 2015-05-18 12:10:45 -0400
Storytime::Site Load (0.2ms) SELECT "storytime_sites".* FROM "storytime_sites" WHERE "storytime_sites"."custom_domain" = $1 LIMIT 1 [["custom_domain", "localhost"]]
Storytime::Site Load (0.3ms) SELECT "storytime_sites".* FROM "storytime_sites" ORDER BY "storytime_sites"."id" ASC LIMIT 1
Storytime::Post Load (0.2ms) SELECT "storytime_posts".* FROM "storytime_posts" WHERE "storytime_posts"."id" = $1 LIMIT 1 [["id", 1]]
Processing by Storytime::BlogHomepageController#show as HTML
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 ["id", 1] SELECT COUNT() FROM "storytime_sites"
CACHE (0.0ms) SELECT "storytime_sites". FROM "storytime_sites" WHERE "storytime_sites"."custom_domain" = $1 LIMIT 1 [["custom_domain", "localhost"]]
CACHE (0.0ms) SELECT "storytime_sites".* FROM "storytime_sites" ORDER BY "storytime_sites"."id" ASC LIMIT 1
Storytime::Post Load (0.2ms) SELECT "storytime_posts".* FROM "storytime_posts" WHERE "storytime_posts"."site_id" = $1 AND "storytime_posts"."id" = $2 LIMIT 1 [["site_id", 1], ["id", 1]]
Redirected to http://localhost:3000/news/blog
Completed 301 Moved Permanently in 8ms (ActiveRecord: 0.7ms)
Started GET "/news/blog" for ::1 at 2015-05-18 12:10:45 -0400
Storytime::Site Load (0.2ms) SELECT "storytime_sites".* FROM "storytime_sites" WHERE "storytime_sites"."custom_domain" = $1 LIMIT 1 [["custom_domain", "localhost"]]
Storytime::Site Load (0.4ms) SELECT "storytime_sites".* FROM "storytime_sites" ORDER BY "storytime_sites"."id" ASC LIMIT 1
Storytime::Blog Exists (0.3ms) SELECT 1 AS one FROM "storytime_posts" INNER JOIN "friendly_id_slugs" ON "friendly_id_slugs"."sluggable_id" = "storytime_posts"."id" AND "friendly_id_slugs"."sluggable_type" = $1 WHERE "storytime_posts"."type" IN ('Storytime::Blog') AND "storytime_posts"."site_id" = $2 AND "storytime_posts"."slug" = 'blog' LIMIT 1 [["sluggable_type", "Storytime::Post"], ["site_id", 1]]
Processing by Storytime::BlogsController#show as HTML
Parameters: {"id"=>"blog"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 ["id", 1] SELECT COUNT() FROM "storytime_sites"
CACHE (0.0ms) SELECT "storytime_sites". FROM "storytime_sites" WHERE "storytime_sites"."custom_domain" = $1 LIMIT 1 [["custom_domain", "localhost"]]
CACHE (0.0ms) SELECT "storytime_sites".* FROM "storytime_sites" ORDER BY "storytime_sites"."id" ASC LIMIT 1
Storytime::Post Load (0.3ms) SELECT "storytime_posts".* FROM "storytime_posts" WHERE "storytime_posts"."site_id" = $1 AND (published_at IS NOT NULL) AND (published_at <= '2015-05-18 16:10:45.348662') AND "storytime_posts"."slug" = $2 ORDER BY "storytime_posts"."id" ASC LIMIT 1 [["site_id", 1], ["slug", "blog"]]
Storytime::Post Load (0.3ms) SELECT "storytime_posts".* FROM "storytime_posts" WHERE "storytime_posts"."site_id" = $1 AND "storytime_posts"."id" = $2 LIMIT 1 [["site_id", 1], ["id", 1]]
Redirected to http://localhost:3000/
Filter chain halted as :load_page rendered or redirected
Completed 301 Moved Permanently in 10ms (ActiveRecord: 1.2ms)
Started GET "/" for ::1 at 2015-05-18 12:10:45 -0400
Processing by ArticlesController#index as HTML
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
Article Load (2.0ms) SELECT "articles".* FROM "articles" ORDER BY updated_at DESC
Rendered articles/index.html.erb within layouts/application (193.6ms)
State Load (0.4ms) SELECT "states".* FROM "states"
Rendered layouts/_header.html.erb (3.1ms)
Category Load (0.3ms) SELECT "categories".* FROM "categories"
Rendered layouts/_footer.html.erb (0.1ms)
Completed 200 OK in 638ms (Views: 627.2ms | ActiveRecord: 3.1ms)
I am not sure if this relates at all to having FriendlyId incorporated on the rest of the site or not.
@campgurus, a few questions for you:
- Which version of Storytime are you using?
- Where did you end up mounting Storytime?
- Under the Site Settings, what "Post URL Style" is being used?
version is storytime (2.0.0)
I mounted it at /news
post url style is default
checking something else, I think it may be that the index view doesn't exist for some reason:
~/development/blackops$ rails g storytime:views -p [blog]
exist app/views/storytime/application
identical app/views/storytime/application/storytime/_disqus_comment_counts.html.erb
identical app/views/storytime/application/storytime/_flash.html.erb
identical app/views/storytime/application/storytime/_footer.html.erb
identical app/views/storytime/application/storytime/_header.html.erb
identical app/views/storytime/application/storytime/_navigation.html.erb
Could not find "blog_posts" in any of your source paths. Your current source paths are:
/Users/dariusgoore/development/blackops/lib/templates/storytime/views
/Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/storytime-2.0.0/app/views/storytime
A fix is currently in the dev
branch. Check it out and let us know if that fixes this issue for you.
That works. thanks very much!