Forum: Ruby on Rails Help about CMS - newbie in RoR

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8d9c6b4bb7aaf51cfc8e9236067bb899?d=identicon&s=25 "A. Martín" (Guest)
on 2006-05-30 20:29
(Received via mailing list)
Hi team, I'm a very newbie RoR user from Spain and I'm developing a
blog's CMS. Why RoR?, coz I think it's an amazing framework with many
posibilities, portable and really powerful, with a young and optimist
community, and taking my project I've prefered his structure in front of
LAMP. Another thing is that I've liked to surprise my masters with this
novel framework. I wish come here to contribute when my application is
finished and when my knowledge in RoR grows.

By now I need some basic help (some directives) about blog creation.
I've developed account administration with auth_generator plugin and
touching some code, but I don't know how can I make every user will
create and configure only one blog at a time (it's 1 user = 1 blog, 1:1
relation).

CONSIDERATIONS:

1 user has 1 blog
1 blog has 1 style and belongs to 1 category
1 blog has many articles
1 blog has many links
1 article has many comments

MySQL database script:

DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
  `id` int(11) NOT NULL auto_increment,
  `login` varchar(80) character set latin1 default NULL,
  `cryptpassword` varchar(40) character set latin1 default NULL,
  `validkey` varchar(40) character set latin1 default NULL,
  `email` varchar(100) character set latin1 NOT NULL default '',
  `newemail` varchar(100) character set latin1 default NULL,
  `ipaddr` varchar(15) character set latin1 NOT NULL default '',
  `created_at` datetime NOT NULL default '0000-00-00 00:00:00',
  `updated_at` datetime NOT NULL default '0000-00-00 00:00:00',
  `confirmed` tinyint(1) NOT NULL default '0',
  `domains` text character set latin1 collate latin1_bin NOT NULL,
  `image` text character set latin1,
  `firstname` varchar(40) character set latin1 NOT NULL default '',
  `lastname` varchar(40) character set latin1 NOT NULL default '',
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;

DROP TABLE IF EXISTS `blogs`;
CREATE TABLE `blogs` (
  `id` int(11) NOT NULL auto_increment,
  `category_id` int(11) NOT NULL,
  `style_id` int(11) NOT NULL,
  `title` varchar(255) character set latin1 default NULL,
  `url` varchar(255) character set latin1 default NULL,
  `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 `articles`;
CREATE TABLE `articles` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(255) character set latin1 default NULL,
  `excerpt` text character set latin1,
  `body` text character set latin1,
  `allow_comments` tinyint(1) NOT NULL default '1',
  `published` tinyint(1) NOT NULL 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;

DROP TABLE IF EXISTS `categories`;
CREATE TABLE `categories` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(255) character set latin1 default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;

DROP TABLE IF EXISTS `styles`;
CREATE TABLE `styles` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(255) character set latin1 default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;

DROP TABLE IF EXISTS `links`;
CREATE TABLE `barbatos`.`links` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(255) character set latin1 default NULL,
  `url` varchar(150) character set latin1 default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;


After creating scaffold with script generator I've touched models like
this:
/app/models/blog.rb
    class Blog < ActiveRecord::Base
        belongs_to :category
        belongs_to :user
        ...
    end

/app/models/user.rb
    class User < ActiveRecord::Base
        has_one :blog
        ...
    end

And at the end I've touched auth_generator account menu (from layout)
adding a link to new blog:
<div class="menu">
        ...
       <%= if @user and @user.ident == true
           link_to(image_tag("#{@app['controller_name']}/letsblog",
:border => 0), {:controller => "admin/blog", :action => "new" } )
       end %>
</div>

But any user can create infinite blogs from his link on menu and can
list and edit other user's blogs using navigator's bar. List option
problem is easy to resolve by erasing this action on blog' controller,
but not so about edit and create options.

Thanks to all, and I wish my newbie problems and my english won't
suppose an annoyance to you :)


______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com
D4ecf6097193e43bf0bf6ea186fcfbd0?d=identicon&s=25 matthibcn (Guest)
on 2006-05-30 21:32
(Received via mailing list)
A. Martín schrieb:
> touching some code, but I don't know how can I make every user will
> create and configure only one blog at a time (it's 1 user = 1 blog,
> 1:1 relation).
Buenos dias,

I would recommend you get a copy of "Typo", that is a railsBlogSystem
and a copy of one of the CMS appraoches allready started

Looking at their code, structure etc would be the best way to see how
you can reach your goal using rails...

Pues nada mas,

regards

matthi
8d9c6b4bb7aaf51cfc8e9236067bb899?d=identicon&s=25 "A. Martín" (Guest)
on 2006-05-30 23:49
(Received via mailing list)
matthibcn
escribió:
> regards
>
> matthi


OK, I'll take a look and check it out. Before installing I need to
configure a php server which I have not.

merci matthi :)


______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com
8d9c6b4bb7aaf51cfc8e9236067bb899?d=identicon&s=25 "A. Martín" (Guest)
on 2006-05-31 00:33
(Received via mailing list)
A.
Martín escribió:
>>
>> regards
>>
>> matthi
>
>
>
> OK, I'll take a look and check it out. Before installing I need to
> configure a php server which I have not.
>
> merci matthi :)

ADVICE: Instant Rails has a Typo project on board, so it isn't necesary
installing an Apache server ^_^


______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com
This topic is locked and can not be replied to.