Open rusikf opened 9 years ago
The redirect makes it so that your blog post url's use the slug style selected in the site settings. I'm not 100% sure why we don't do that same redirect if you're previewing the post though. Let me look into that and get back to you.
— Sent from Mailbox
On Mon, Apr 13, 2015 at 4:31 PM, Ruslan Korolev notifications@github.com wrote:
Hello all ruby hackers ! Question: Why checking
params[:preview]
for nil and redirecting is really needed?:if params[:preview].nil? && !view_context.current_page?(storytime.post_path(@post)) redirect_to storytime.post_path(@post), :status => :moved_permanently
More code you can find in source Just for fun, I researched this problem and added this route:
get '/hack_blog_posts/:id', to: 'posts#show'
Created blogpost, which have id=3 Open a browser onlocalhost:3000/hack_blog_post/3
And was redirected to http://localhost:3000/posts/my-blog-post Why redirect here should be ? Of'course If i added preview GET param, there is a flash notice and no redirect BUT If I comment all this lines, the view renders successfully on localhost:3000/hack_blog_post/3 without redirect, so i can't understand why condition, described above is needed.(there is no problems as I can see at a first glance):#if params[:preview].nil? && !view_context.current_page?(storytime.post_path(@post)) #redirect_to storytime.post_path(@post), :status => :moved_permanently #elsif lookup_context.template_exists?("storytime/#{@current_storytime_site.custom_view_path}/#{@post.type_name.pluralize}/#{@post.slug}") # render "storytime/#{@current_storytime_site.custom_view_path}/#{@post.type_name.pluralize}/#{@post.slug}" #elsif !lookup_show_template_override.nil? #render lookup_show_template_override #end
@dvanderbeek, may be you can help me with this problem?( commit in the past.)
Reply to this email directly or view it on GitHub: https://github.com/FlyoverWorks/storytime/issues/130
Hello all ruby hackers ! Question: Why checking
params[:preview]
for nil and redirecting is really needed?:More code you can find in source
Just for fun, I researched this problem and added this route:
get '/hack_blog_posts/:id', to: 'posts#show'
Created blogpost, which have id=3 Open a browser onlocalhost:3000/hack_blog_post/3
And was redirected to http://localhost:3000/posts/my-blog-post Why redirect here should be ? Of'course If i added preview GET param, there is a flash notice and no redirectBUT If I comment all this lines, the view renders successfully on localhost:3000/hack_blog_post/3 without redirect, so i can't understand why condition, described above is needed.(there is no problems as I can see at a first glance):
@dvanderbeek, may be you can help me with this problem?( commit in the past.)