Displaying 8 results from an estimated 8 matches for "post_url".
2009 Dec 03
2
Dynamic Paths
..._id
where the user has_many posts and the post belongs_to user. I''m using the
friendly_id plugin to enable easy lookup with the user''s username, and I
would like to have the blog paths automatically retrieved, instead of
getting a path error (as such):
ActionView::TemplateError (post_url failed to generate from
{:controller=>"posts", :user_id=>#<Post id: 1, user_id: 5, title: "Rock and
Roll", body: "This is my blog post body.", created_at: "2009-12-03
15:40:06", updated_at: "2009-12-03 15:40:06">, :action=>"show&...
2006 Jun 09
9
Opinions on catch-all routing?
I remember reading somewhere a tip on improving your search engine
ranking, by forming URLs that included relevant text, e.g.
www.domain.com/article/man_eats_hat. In the rails app that I''m writing,
I''ve noticed I can set this up very easily by appending the post title
(after downcase.split.join(''_'')) to the post link. So, blog.com/posts/4
can easily also be
2007 Jul 31
0
Edit not working with named routes
...layout "blog"
before_filter :login_required, :except => [:index, :show]
before_filter :find_post, :except => [:index, :new, :create]
def edit
end
def update
if @post.update_attributes(params[:post])
flash[:notice] = "Post Updated"
redirect_to post_url(@post)
else
render edit_post_url
end
end
protected
def find_post
@post = Post.find(params[:id])
end
end
Here is edit.hrtml
<h1>New Post</h1>
<% form_for(:post, @post, :url => post_url(@post), :html => {:method
=> ''put''}) do |f|...
2012 Apr 04
1
Subscript Error
json_dir is a list of JSON lists mapping lat/long route points between
locations using CloudMade's API.
post_url is the URL of the HTTP request
for (n in json_dir) {
i = i + 1
if (typeof(json_dir[[i]]) != "NULL") {
if (i == 1) {
dat_add <- ldply(json_dir[[i]], function(x)
t(data.frame(x)), .progress = "text")...
2007 Jan 02
4
allow stubbing of previously defined methods such as "id"
On my current project I needed to create a stub that responded
correctly to the id message. Here''s the change I put into my copy of
head.
Index: lib/mocha/mock_methods.rb
===================================================================
--- lib/mocha/mock_methods.rb (revision 1114)
+++ lib/mocha/mock_methods.rb (working copy)
@@ -68,6 +68,7 @@
method_names =
2007 Jun 01
0
Okay, new question - dealing w/ logging in restrictions (controller?)
...ymore.
Anyway, so my controller has a before_filter on the edit action; which
checks to see if the current post''s user, is the same as the currently
logged in user, if true then they can edit, otherwise not.
def check_user
if current_user.login != @post.user.login
redirect_to post_url(@post)
end
end
Now I can easily test this functionality by seeing if I get redirected
if I hit that page, but what if I actually want to be logged in, so I
can test to see if the edit action is working?
Any input on this?
Thanks.
--
-Daniel Fischer
http://danielfischer.com - Geek Blog
h...
2010 Apr 22
0
How to automatically set params based on passed object when generating a route?
...ving i.e. a post model that has many categories - is it possible for
member routes like i.e. post_path(post) to generate path like "/
posts/:post_category_name/:post_id" without manually passing the
category param? Does anyone know if there''s a gem or if I can simply
override the post_url method to automatically set category from post
object?
The best I could get right now is post_path(post.category, post), but
while it doesn''t look awful it still breaks all links in my app where
most of the time I generate links using link_to(post.title, post).
Cheers,
Szymon
--
You re...
2007 May 31
16
Could anyone please help with rspec/nested resource behavior checking?
My problem has been listed here:
http://railsforum.com/viewtopic.php?pid=25439#p25439
Don''t think it would be required to completely re-type it here :)
Thanks!
--
-Daniel Fischer
http://danielfischer.com - Geek Blog
http://abigfisch.com - Portfolio
http://writersbeat.com - Writing Community