Displaying 14 results from an estimated 14 matches for "blog_id".
Did you mean:
log_id
2006 Oct 07
3
blog_id magic with typo
Hi All,
I am modifying typo so as, I can host multiple blogs on the same typo.
And its almost done, except that...i am stuck at one place.
When a user posts a new article, depending upon current blog_id, I
would like to set the blog_id attribute of @article object.
So..in the admin/content_controller.rb:
We have:
def new_or_edit
if request.post?
set_article_author
save_attachments
logger.info("**** and blog id in article is #{@article.blog_id}")
if @article...
2006 Jan 31
4
Rails bug? Conditions on associations ignored by eager loading
...ions defined,
the conditions are ignored.
The following example illustrates the problem. I have two tables:
create_table "blogs", :force => true do |t|
t.column "name", :string
end
create_table "posts", :force => true do |t|
t.column "blog_id", :integer
t.column "subject", :string
t.column "published", :boolean
end
The model for blogs looks like this:
class Blog < ActiveRecord::Base
has_many :posts
has_many :published_posts, :class_name => ''Post'', :foreign_key...
2006 Sep 07
6
form_for - Child object - how to set parent id
Hi All,
I am just trying to learn ruby/rails so please don''t flame me if this is
a stupid question.
As a learning project I decided to create my own blog using ROR. I have
created a controller that shows paged blog entries, and below each blog
is a list of comments along with a form alowing the user to add a new
comment.
To create the form for the comment entry I used form_for
2010 Aug 15
0
Singular resources namespaced by its slug (Routing)
Hi,
I have the followed Rails 3 routes:
Hello::Application.routes.draw do
resources :blogs do
resources :articles do
resources :comments
end
end
end
By raking them, we can find (for instance):
GET /blogs/:blog_id/articles(.:format) {:action=>"index",
:controller=>"articles"}
Because every routes begin with the same root path (*/blogs*), I would
like to shorten addresses by removing it (when :blog_id is given).
In this why, I could have thoses routes (I think it''s mo...
2006 Jul 17
2
Trouble with has_one
...used:
-----------------------------------
def uploadImage
Post.find(params[:id]).images.create(params[:image])
@post = Post.find(params[:id])
flash[:notice] = "Image was successfully uploaded"
redirect_to :action => ''showBlogPosts'', :id => @post.blog_id
end
def uploadHeaderImage
Post.find(params[:id]).header.create(params[:header])
@post = Post.find(params[:id])
flash[:notice] = "Image was successfully uploaded"
redirect_to :action => ''showBlogPosts'', :id => @post.blog_id
end
As you can see...
2008 Oct 09
2
has_many validation the Rails way
...hing I run into a lot and don''t really have a great
solution. Here is a simple example:
class Blog < ActiveRecord::Base
has_many :posts
validates_presence_of :name
end
class Post < ActiveRecord::Base
belongs_to :blog
validates_presence_of :name
validates_presence_of :blog_id
end
Now, if I want to create a blog and post at the same time I don''t want
either to be created if one of them fails. So imagine that I have a
new valid blog, but a post with no name. I do not want the blog to be
created because the post failed validation.
Thanks,
Tom
--~--~---------~-...
2006 Jul 24
7
[PATCH] Support for DB Clusters/Replication in ActiveRecord (RFC)
Skipped content of type multipart/alternative-------------- next part --------------
Index: connection_adapters/abstract/connection_specification.rb
===================================================================
--- connection_adapters/abstract/connection_specification.rb (revision 4617)
+++ connection_adapters/abstract/connection_specification.rb (working copy)
@@ -1,10 +1,21 @@
require
2007 Feb 01
4
Automatically Indexing Associated Models
...ectly searchable.
However, when a comment is added to a blog, that comment does not get
added to the index and is therefore not ferretable. The desired behavior
is that when a comment is added to a blog, that the comment be
ferretable.
CURRENT SETUP
Blog (id, title, body, user_id)
BlogComment (id, blog_id, comment)
class Blog < ActiveRecord::Base
has_many :blog_comments, :dependent => :destroy
acts_as_ferret :additional_fields => [:blog_comments]
def blog_comments
self.blog_comments.collect {|comment| comment.body }
end
end
class BlogComment < ActiveRecord::Base
belongs...
2009 Feb 22
8
dynamically changing a form from POST/CREATE to PUT/UPDATE
For the life of me I can''t figure this one out, although I can''t find
anyone else who''s attempted to do this, and probably with good reason.
Context: blog using AJAX
What I''m trying to do: when the user initially saves a blog entry, or
when auto-saving, I want subsequent saves to not create a new blog
entry
Why I can''t just reload the partial:
-
2006 May 27
0
Typo 1055 created_at Vs. published_at
...s changed
in the admin interface.
app/controllers/articles_contoller.rb
line 19
def index
@pages, @articles =
paginate(:article, :per_page => this_blog.limit_article_display,
:conditions =>
[''published = ? AND contents.created_at < ? AND blog_id
= ?'',
true, Time.now,
this_blog.id],
#:order_by => "contents.created_at DESC", - Changed to
published_at by Ed Gard 5/27/06
:order_by => "contents.published_at DESC",
:include =>...
2005 Dec 18
0
Caching question
...iteOptionHash("Home")
@header_image = @siteoption["header_image"]
@header_text = @siteoption["header_text"]
@blogentry_pages, @blogentries = paginate :blogentry, :per_page => 10,
:order_by => ''created_on asc'', :conditions => "blog_id = 10"
render(:template => "/home/index")
end
def home
render(:action => :index)
end
end
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/ra...
2006 Feb 07
1
habtm :uniq causing duplicate inserts? How to update Rails?
Hello *Gem* experts,
Sorry for asking multiple questions in one post but they are both related to one problem.
So far I have the following code:
class Member < ActiveRecord::Base
has_and_belongs_to_many :blogs, :uniq=>true
.....
end
class Blog < ActiveRecord::Base
has_and_belongs_to_many :members, :uniq=>true
...
end
The issue is that
2006 Jul 01
4
How to create Multi-User webapplication?
I''m kinda nuby! and i just want to know how to create a Multi-User Web
application, where a person can register and can have his own subdomain
for a blog.. where people can view and visit it....
--
Posted via http://www.ruby-forum.com/.
2006 May 30
3
Help about CMS - newbie in RoR
...L default ''1'',
`created_at` datetime default NULL,
`updated_at` datetime default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;
DROP TABLE IF EXISTS `comments`;
CREATE TABLE `comments` (
`id` int(11) NOT NULL auto_increment,
`blog_id` int(11) NOT NULL,
`email` varchar(150) character set latin1 default NULL,
`author` varchar(255) character set latin1 default NULL,
`body` text character set latin1,
`created_at` datetime default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;...