RailsFan Radha wrote:
> Hassan Schroeder wrote:
>> On Sat, Jun 26, 2010 at 11:56 AM, RailsFan Radha <li...@ruby-forum.com> 
>> wrote:
>> 
>>> given this scenario, if this is an existing db, how could we create the
>>> CRUD pages for this without doing migration.
>> 
>> There's an active_scaffold plugin that (I believe) replicates the old
>> 1.x Rails dynamic scaffolding. I've never used it, but it might work.
>> 
>> Otherwise, you'll just have to write your views, tests, etc. yourself.
>> 
>> HTH,
>> --
>> Hassan Schroeder ------------------------ hassan.schroe...@gmail.com
>> twitter: @hassan
> 
> 
> i'll check active scaffold plugin. as i googled, a few had specified 
> that it isn't working as specified. i am yet to delve into it. will keep 
> it posted as i delve into it.
> 
> 
> 


> apart from that.. today, the very first page in the CRUD pages started 
> working.
> Created a "list" page to list all categories and it listed all.
> used the steps from: 
> http://www.tutorialspoint.com/ruby-on-rails/rails-views.htm
> 
> in the similar approach , will try to create the other CRUD pages too.
> 
> 
> here are the pages:
> ################### model ###########################
> ##################category.rb########################
> ../app/models# more category.rb
> class Category < ActiveRecord::Base
> set_table_name 'category'
> set_primary_key "category_id"
> 
> def self.find_all_categories
>   find(:all)
> end
> end
> #####################################################
> 
> ##################controller#####################
> ##############category_controller.rb#############
> app/controllers# more category_controller.rb
> class CategoryController < ApplicationController
>     def index
>   # "List all categories"
>   list
>   render:action=>'list'
>     end
>    #--- List--
>    def list
>    @categories=Category.find_all_categories
>   end
> 
> end
> ##################################################
> 
> ###################### views######################
> ######################list.erb####################
> ../app/views/category# more list.erb
> 
> <h1>list template for category <h1>
> 
> <% if @categories.blank? %>
> <p>There are not any categories currently in the system.</p>
> <% else %>
> <p>These are the current categories in our system</p>
> <ul id="categories">
> <% @categories.each do |c| %>
> <li><%= link_to c.category_title, {:action => 'show', :id => 
> c.category_id} -%><
> /li>
> <% end %>
> </ul>
> <% end %>
> 
> ####################################################
> 
> Summary:
> --------
> For one controller and one action, these three files were 
> created/modified:
> Currenlty, these three flles does only one action, which is "listing" 
> all categories from the "category table". I think atleast one part of 
> the CRUD is done. can we say so? I guess so.
> Files modified:
> --------------
> model/category.rb
> controller/category_controller.rb
> views/list.erb
> 
> the next step is to prep for the "edit" action for category.
> 
> please let me know if i'm missing any.
>
> thanks again,
> radha.



Update to this post:

"show" action for this category has been done. I think this is one among 
the CRUD pages. (create, read, update, delete)
I guess, show => read

The following pages are created/modified for this "show" action for 
"category" controller:
------------------------------------------------------------------------------
app/controller/category_controller.rb ( added show def to this file)
app/views/category/show.erb  (new template created. this is a new file)


##################  app/controller/category_controller.rb  ###########
  def show
     @category=Category.find(params[:category_id])
  end

#######################################################################

###################   view  ##########################################
/app/views/category# more show.erb
<h1><%= @category.category_title %></h1>
<p><strong>Title: </strong> $<%= @category.category_title %><br />
<strong>Short_Description :</strong> <%= @category.category_short_desc 
%><br />
<strong>Long_Description :</strong> <%= @category.category_long_desc 
%><br />
<strong>Status :</strong> <%= @category.status%><br />

<strong>Created Date:</strong> <%= @category.dt_created %><br />
<strong>Modified Date:</strong> <%= @category.dt_modified %><br />
<strong>Created User:</strong> <%= @category.user_created %><br />
<strong>Modified User:</strong> <%= @category.user_modified %><br />
</p>
<p><%= @category.category_title %></p>
<hr />
<%= link_to 'Back', {:action => 'list'} %>
################.#################################


Summary:
-----------------
To create the "show" action, controller file was modified and a new view 
template was created.
Model remains inchanged.

So, this works!
The link created in the abover list.erb, shows this show.erb page when 
clicked.
The link works and that means the "show" action is working.

------------------------
Please let me know if I'm missing any in this route.


Just thought of updating this here, as this inspires me to move forward, 
thinking i have people here to discuss with.
that makes all the big difference.

I will keep you all posted.

- thanks again,
radha.

-- 
Posted via http://www.ruby-forum.com/.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to