Displaying 20 results from an estimated 78 matches for "post_id".
2008 Apr 14
2
Problems with nil object
...very loing, but
please, try to read it. I have a simply blog, with posts and their
comments. I''ve two tables in my db, posts, with post id, text and
comments_count to store the number of comments-children of each post (as
recomanded to do in AWDWR); and the table comments, with comment id,
post_id for the post they''re referred to, and text (there are many other
fields, but they''re not importat here). I have a home_controller, this
is the code:
class HomeController < ApplicationController
def index
@posts = Post.find(:all, :order => "data DESC")...
2007 May 31
4
Sample Merb App
I put together a sample app to help people learn Merb:
http://svn.depixelate.com/applications/invoice_tracker/
I also blogged about it here:
http://depixelate.com/2007/5/31/taking-merb-for-a-spin
--
Zack Chandler
http://depixelate.com
2006 Jun 08
5
Displaying Calculation on Index
Hi, I am trying to create a simple point system and display the total on
my index page. So I have my db basically setup like this:
Posts
id, body, created_at, user_id
Post_points
id, post_id, user_id, created_at, value
So as you can see I am allowing other users to create points on the post
and my db will store who gave the point as well. "value" is the point
value which can either be -1 or 1. Basically I just want to add these
points together for a given post_id and di...
2006 Apr 08
2
trouble expiring cached pages
...ting my cached pages to expire. Maybe
one of you guys can help me out. I''ll show my sweeper and then my log
to show that it "should" be working.
class PragmaticSweeper < ActionController::Caching::Sweeper
observe Comment
def after_save(comment)
expire_page(comment.post_id)
end
private
def expire_page(post_id)
logger.error("I made it to the caching method in the SWEEPER!!!!!!")
expire_action(:controller => ''pragmatic'',
:action => ''view'',
:id => post_i...
2006 Aug 03
6
Listing all of a nested Resources
I''ll use the example on the Rails blog.
map.resources :posts do |posts|
posts.resources :comments, :trackbacks
end
Now comments are at /posts/:post_id/comments.
Okay but what if I want to list all the comments for all the posts. It
should be at /comments, but that isn''t map that way. Can I map comments
twice?
--
Posted via http://www.ruby-forum.com/.
2009 Apr 15
2
Getting Started with Rails - post_comment_url
...to the last
section and just added the comments part.
So while testing and looking over comments_controller.rb;
I see the reference to post_comment_url calll where is this defined.
Below is the message I am getting.
Thanks
ActionController::RoutingError (post_comment_url failed to generate
from {:post_id=>#<Post id: 1, name: "lin", title: "post 1", content:
"content 1", created_at: "2009-04-15 16:56:44", updated_at:
"2009-04-15 16:56:44">, :action=>"show", :id=>#<Comment id: nil,
commenter: "jake lin", body: &qu...
2009 Aug 16
5
any help with captcha in my comments ?
this is my error:
Processing ApplicationController#create (for 127.0.0.1 at 2009-08-17
00:57:56) [POST]
Parameters: {"comment"=>{"name"=>"asdasd", "body"=>"asdasd"},
"commit"=>"Add Comment", "post_id"=>"19",
"authenticity_token"=>"B5dll5fTaDO+ZrEs1S0KkYsmK8VMzCOeDEf731w21zY=",
"captcha"=>"asdasd", "_"=>""}
SyntaxError
(/Users/webstic/Sites/weblog/app/controllers/comments_controller.rb:11:
syntax error, unexp...
2005 Mar 10
10
Some Basic Questions
Sorry I can''t access IRC from work so I hope you don''t mind me asking my newbie
questions here:
1) I have the following code:
@post = Post.find(@params[''id''])
@comments = Comment.find_all "post_id = #@params[''id'']", "created_on ASC"
And I am have problems with the second line. I want to pass the id from my post
to the comments line to get the comments for that post. What am I doing wrong?
I tried a ton of different ways and they all don''t work
2...
2006 Jul 04
8
writing to many_to_many table
I have three tables. users, posts, users_posts. This last one is to
mark a post as read.
How do I write to the users_post table?
Here''s what I have:
In model ''User_Post''
belongs_to :post
belongs_to :user
In post/view/show:
<%= link_to "Mark As Read", :controller => ''post'', :action =>
''post_read'',
:user =>
2006 Apr 20
1
Returning Count from find_by_sql
I want to return an int from a find_by_sql call. But when I use that
result to compare to another count the error tells me I have an array.
MODEL:
# Returns the number of comments in a specified post
def self.find_count(post_id)
find_by_sql(["SELECT COUNT(*) FROM commments WHERE post_id = ?",
post_id])
end
CONTROLLER:
def test
@post = Post.find(@params["post_id"])
@comment =
Comment.find_next(@params["post_id"], @params["position"])...
2007 Nov 12
7
schema_info always wants to be 3, even when set to 7
Hi all,
I''m having a very odd problem with db:migrate. I''m using Rails 1.2.5
on Windows XP SP2 and Ruby 1.8.6
I have seven migrations. If I run them with an empty database, it
runs the first three, then halts. When I look in schema_info, the
version is 3.
If I run db:migrate VERSION=7, then it runs through the remaining 4
migrations, and the version is 7 in the DB.
2006 Aug 31
0
ActiveResource
...ap.resources :posts do |post|
post.resources :comments
end
# ActiveResources
class Post < ActiveResource::Base
self.site = "http://37s.sunrise.i:3000/"
end
class Comment < ActiveResource::Base
self.site = "http://37s.sunrise.i:3000/posts/:post_id/"
end
@post = Post.find 5
@comments = Comment.find :all, :post_id => @post.id
@comment = Comment.new({:body => ''hello world''}, {:post_id => @post.id})
@comment.save
One thought I''ve had is splitting the prefix options from the
att...
2006 Feb 24
4
too many components?
...39;', :action=>''display_comments'',
:id=>post.id)
on comments/display_comments
i iterate through the comments and then, display_comments.rhtml
render_component(:controller=>''comments'', :action=>''new'', :id=>@id)
(@id is the post_id)
so this is all works okay, i can add the comment and i changed the
redirect to posts/show/@id
problem is, if the new comment form fails (say, i dont'' put in a
required author field), it redirects to /comments/new/ to give me an
error message when i really wnat that error message to b...
2006 Oct 16
6
Rails AR/Oracle Unit Test: [5310] failed (but getting better)
...''
2) Failure:
test_eager_with_has_many_through_join_model_with_conditions(EagerAssociationTest) [./test/associations/eager_test.rb:126]:
<[#<SpecialComment:0x45f99b00 @attributes={"body"=>"Special type", "type"=>"SpecialComment", "post_id"=>4, "id"=>6}>, #<SpecialComment:0x45f9229c @attributes={"body"=>"Special type 2", "type"=>"SpecialComment", "post_id"=>4, "id"=>7}>, #<VerySpecialComment:0x45f8bca8 @attributes={"body"...
2012 Mar 12
4
how to design a api?
hi,everyone.
now i start to design a api.
the url like this
http://localhost:3000/api?seckey=123&&post_id=1
the visitor need a seckey to access auth.and get info via json.
so i dont think thats a good api.
i need your answers.thx
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk-/JY...
2006 Jul 03
0
Check if row already exists?
I''m working on a system that has a series od "bids" associated with
"posts". Vurrently when a bid is placed I have it creating a new row
each time in the "bids" table. The bids table has id, post_id, and
user_id.
The logic is to check to see if a bid already exists with a given
post_id and user_id. If it does, then just update the "amount" field. If
it doesn''t, then create a new line. Here''s what I have to create the
row:
def
@post = Post.find(params[:post...
2007 Jan 01
0
Simple question on inserting child data
...g I have finally sat down to create a
simple app to dirve home a lor of the concepts to which have been read.
So I figured a simple blog app is the best way to do it. The bad
thing is that I am already hung up when creating replies to a blog
posting.
I can''t figure out how to insert the post_id value into the reply
table. When creating a reply the user is directed to a page via a url
simular to the following http://localhost:3000/main/reply/4, with the
value 4 being the post_id that is being replied to.
In the controller I have:
class MainController < ApplicationController
def in...
2006 Jan 09
1
AR: Quoting in Join Model Test
...things are sometimes symptomatic of
a larger, more fundamental problem with the way I''m handling things,
I thought I should ask.
For your convience, here is the test in question:
def test_has_many_with_piggyback
assert_equal "2", categories(:sti_test).authors.first.post_id
end
-Derrick Spell
"Perl''s grammar can not be reduced to BNF.
The work of parsing perl is distributed between
yacc, the lexer, smoke and mirrors.''''
-Chaim Frenkel
2009 Dec 03
2
Dynamic Paths
Hey there,
I''m in the muck of a major rails project, and need a bit of advice. Google
isn''t much help in this case, so I came here.
I''m trying to set up a URL structure as follows:
url.com/username/blog/post_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 (pos...
2006 Jul 22
12
Community request - can someone show me REST?
I mentioned this in another thread, but I''ve got a formal request now.
After reading tons of stuff about REST, I don''t really get it. I
need to see an example.
I''d like someone to write up an example blog app with these requirements
- RESTful using the simply_restful plugin (or edge rails)
- allows posting of comments to articles
- has categories for posts
No need