Displaying 20 results from an estimated 900 matches similar to: "Unable to delete post in sample blog application"
2010 Jan 05
0
Problem with associating comments with blog posts on same page
Hi,
I will admit I am very new to ruby and I am trying to do something
that is not in any tutorials I have found. If you see a more
conventional way to do some of the things I am trying to do, please
let me know.
What I am trying to accomplish. People can edit the comments on the
same page as the listing of posts. The problem is that when I go to
create the comment, it is not getting associated
2006 Jul 12
1
odd habtm behavior? or is it me?
Hello List,
I''m a bit spent on this problem, and my code might be whack. I seem to be
encountering a problem where the primary key on a join table is not being
resolved correctly. I will elaborate after some code bits. I am creating
the join table using migrations, and relevant model code is this:
class Post < ActiveRecord::Base
has_and_belongs_to_many :records
2010 Apr 14
0
Rails 3 (beta3) and paths in the console
Did I miss some release note somewhere? I used to be able to, from the
Rails console, get paths and urls using:
app.posts_path or app.post_path(p)
Now, trying to do that, I get an error stating that those methods are
protected?
irb(main):001:0> app.posts_path
NoMethodError: protected method `posts_path’ called for
#<actiondispatch::integration::session:0x3bf67c0>
(Windows, Rails
2008 Apr 14
2
Problems with nil object
Hi to all. I''ve a very big problem. I know this can seem 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
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 =
2006 Apr 08
2
trouble expiring cached pages
I''m having a bear of a time getting 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)
2009 Apr 15
2
Getting Started with Rails - post_comment_url
Hi,
Thanks for a wonderful Getting Started with Rails. I am up 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:
2006 Aug 31
0
ActiveResource
I''ve been sitting on an ActiveResource patch for a few weeks, waiting
to get some feedback from David. But, I see other folks like Jeremy
are starting to use it, so I committed my patch:
http://dev.rubyonrails.org/changeset/4890
It gets all the basic operations in working order, and adds support
for prefixes. I wasn''t quite sure how to pull this off. Right now,
I''m
2009 Jul 26
2
How knows my paths in link_to? If I do not defined.
Hello,
It´s my first post here. :)
I´l following the guide of Ruby, but I need to know how the Ruby knows
my path to other pages if I did not define anything, like this:
app/views/posts/index.html.erb:
<td><%= link_to ''Show'', post %></td>
<td><%= link_to ''Edit'', edit_post_path(post) %></td>
Other
2006 Oct 16
6
Rails AR/Oracle Unit Test: [5310] failed (but getting better)
"rick" has given AR/Oracle some love, but it''s still unhappy...
http://dev.rubyonrails.org/changeset/5310
------------------------------------------------------------------------
r5310 | rick | 2006-10-16 08:42:55 -0700 (Mon, 16 Oct 2006) | 1 line
Fix has_many :through to add the appropriate conditions when going through an association using STI. Closes #5783. [Jonathan Viney]
2012 Apr 09
8
Rails Functional Testing Problem
I''m trying to run some functional tests on Rails. However I am coming up
with the following error.
RuntimeError: Called id for nil, which would mistakenly be 4 -- if you
really wanted the id of nil, use object_id
app/controllers/posts_controller.rb:11:in `create''
posts_controller_test.rb:5:in `test_should_create''
Here is my test file
require
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"
2007 Jan 01
0
Simple question on inserting child data
after doing a bunch of reading 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
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
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",
2010 Apr 17
1
Nil.to_sym Problem
HI everyone, require some help! cannot figure out this error and how
to fix it!
Showing user/index.html.erb where line #59 raised:
You have a nil object when you didn''t expect it!
The error occurred while evaluating nil.to_sym
Extracted source (around line #59):
56: <% end %>
57: </ol>
58:
59: <div id="hub">Blog: <%= link_to "(manage)",
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/.
2011 Feb 20
3
ugly url form_tag
Hi all
I am using form_tag helper and everything is sent by the get method.
In the url looks like :
http://localhost:3000/posts?utf8=%E2%9C%93&search=rails
The utf8 attributes is pretty much ugly.
Is there a way (in Rails 3) the url looks like something like :
http://localhost:3000/posts/search/rails
If yes what do I need to change in my code ?
Here is my code
<% form_tag posts_path,
2006 Aug 05
0
Another generic CRUD controller
I''ve been using this template on most of my CRUD controllers.
class CommentsController < ApplicationController
meantime_filter :set_scope
before_filter :find_comment, :only => %w(show edit update destroy)
def index
@comments = Comment.find(:all)
end
def new
@Comment = Comment.new
end
def create
@comment = Comment.create!(params[:comment])
2006 Jul 24
1
has_many + finder_sql
from the api I got:
<pre>
has_many :subscribers, :class_name => "Person", :finder_sql =>
''SELECT DISTINCT people.* '' +
''FROM people p, post_subscriptions ps '' +
''WHERE ps.post_id = #{id} AND ps.person_id = p.id '' +
''ORDER BY p.first_name''
</pre>
I would like to pass in the