Google Groups Home
Help | Sign in
newbee Q's - I'm afraid
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  16 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
walt  
View profile
 More options Apr 30, 5:07 am
From: walt <walt...@diechmann.net>
Date: Wed, 30 Apr 2008 02:07:08 -0700 (PDT)
Local: Wed, Apr 30 2008 5:07 am
Subject: newbee Q's - I'm afraid
Hi Ian,

I found my way here - and want to leave my appraisals of your
brilliant r_c with this group :)

My infancy (with r_c) probably explains the subject of this post, but
anyways -

with this:
-------------------------

class ProjectsController < ApplicationController
  inherit_views
end

class SmallProjectsController < ProjectsController
end

class Project < ActiveRecord::Base
  # table holds type (for STI), name, project_cost, and a few other
attributes
  belongs_to :partner
end

class SmallProject < Project
end

class Partner < ActiveRecord::Base
  has_many :projects
end

class Customer < Partner
end

class Supplier < Partner
end
---------

I would like to ask you

- will customers/4/small_projects work?
- is customer_small_projects_url(resource) the correct notation?

How do I use will_paginate with r_c - is it at all possible?

Like I started out in the subject - a lot of newbee questions, I'm
afraid :(

Hope to hear from you :)

best regards,
Walther

ps. is the public lighthouse "draft" still up for grabs ( or will
github suffice?)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian White  
View profile
 More options Apr 30, 6:43 am
From: "Ian White" <ian.w.wh...@gmail.com>
Date: Wed, 30 Apr 2008 11:43:41 +0100
Local: Wed, Apr 30 2008 6:43 am
Subject: Re: newbee Q's - I'm afraid
Hi Walt,

Welcome to the list

>  - will customers/4/small_projects work?

It will if there's a :small_projects association on customers (you
could make one)
(Or, you could make your projects controller know about :type (and
override find/new_resource methods), and route :small_projects to
:projects, :type => 'small_project')

>  - is customer_small_projects_url(resource) the correct notation?

It depends on your routes.rb,
This is just rails though, nothing to do with RC, resource is just a
method pointing to (in this case) a customer

>  How do I use will_paginate with r_c - is it at all possible?

It should be - I have
Just change find_resources to something like this:

def find_resources
  resource_service.paginate(options)
end

>  ps. is the public lighthouse "draft" still up for grabs ( or will
>  github suffice?)

Issue tracker (for bugs and patches, use this group for this sort of
request) is now at lighthouse

http://ianwhite.lighthouseapp.com/

Cheers,
Ian
--
Argument from Design--We build web applications
Western House 239 Western Road Sheffield S10 1LE UK
Mobile: +44 (0)797 4678409 | Office: +44 (0)114 2667712
<http://www.ardes.com/> | <http://blog.ardes.com/ian>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
walt  
View profile
 More options Apr 30, 7:54 pm
From: walt <walt...@diechmann.net>
Date: Wed, 30 Apr 2008 16:54:04 -0700 (PDT)
Local: Wed, Apr 30 2008 7:54 pm
Subject: Re: newbee Q's - I'm afraid
Hi Ian,

sorry - I must have some SPAM filter engaged or-what-not - did not
receive any notification even though I signed up for this list <:)

anyways,

I dug up pagination_find - which somehow seemed to fit the bill - but
now I see your answer, and that will probably lure me into trying out
will_paginate once more :)

I've managed to do the index for /customers/4/small_projects - and
with a one-line patch to pagination_find, I'm able to do nested
pagination like /customers/4/small_projects/5/tasks?page=3

I know this is completely of track but this is what I "patches" into
pagination_find (or rather - the module Helpers) - not pretty and my
ruby illiteracy shines, but it gets me through <:)

    def paginating_links(paginator, options = {}, html_options = {})
      name = options[:name] || DEFAULT_OPTIONS[:name]
      params = (options[:params] || DEFAULT_OPTIONS[:params]).clone
      paginating_links_each(paginator, options) do |n|
        params[name] = n
        # was: link_to(n, params, html_options)
        url = resources_url+"?#{name.to_s}="+n.to_s  # changed
        link_to(n, url, html_options)                            #
changed
      end
    end

Thank you so much for answering - and have a good one!

Walther

ps. should you ever find yourself "stranded" in Jutland or Denmark at
all, please give me a call - I would like to help you to a pint or two
of some of our danish brew (read: beer)  :)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian White  
View profile
 More options May 1, 9:16 am
From: "Ian White" <ian.w.wh...@gmail.com>
Date: Thu, 1 May 2008 14:16:53 +0100
Local: Thurs, May 1 2008 9:16 am
Subject: Re: newbee Q's - I'm afraid
Hi Walt,

I don;t really know much about pagination_find, never used it.

the will_paginate answer might help you out though - basically treat
resource_service like a class or association

>  ps. should you ever find yourself "stranded" in Jutland or Denmark at
>  all, please give me a call - I would like to help you to a pint or two
>  of some of our danish brew (read: beer)  :)

Will do - always up for a beer

Cheers,
Ian

--
Argument from Design--We build web applications
Western House 239 Western Road Sheffield S10 1LE UK
Mobile: +44 (0)797 4678409 | Office: +44 (0)114 2667712
<http://www.ardes.com/> | <http://blog.ardes.com/ian>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
walt  
View profile
 More options May 2, 7:29 am
From: walt <walt...@diechmann.net>
Date: Fri, 2 May 2008 04:29:50 -0700 (PDT)
Local: Fri, May 2 2008 7:29 am
Subject: Re: newbee Q's - I'm afraid
Hi Ian,

the pagination_find is back on the shelf, and will_paginate churning
away with resource_service. Super!

next item on my todo is creating new projects.

on the SmallProjectsController, I'm able to do

def new
  what.ever.needs.done
end

but if I leave out the def on SmallProjectsController, i get the
default action from resources_controller lib - not the action from the
ProjectsController

is that related to r_c - or just standard Rails/Ruby functionality
that you cannot inherit methods?

I've even tried

def new
  super
end

on the SmallProjectsController, but that did not change anything <:(

Why not just def the methods on SmallProjectsController? Well, trying
to DRY my code, I'd sure like to keep as much code as possible on the
ProjectsController - with 8-10 ProjectsController subclassed
controllers on the horizon :)

Cheers
walt


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian White  
View profile
 More options May 2, 7:50 am
From: "Ian White" <ian.w.wh...@gmail.com>
Date: Fri, 2 May 2008 12:50:40 +0100
Local: Fri, May 2 2008 7:50 am
Subject: Re: newbee Q's - I'm afraid
Hi walt,

thanks for your birth advice/musings

If you have SmallProjectsController < ProjectsController
 then you should get the inherited method - is that not happening?

2008/5/2 walt <walt...@diechmann.net>:

--
Argument from Design--We build web applications
Western House 239 Western Road Sheffield S10 1LE UK
Mobile: +44 (0)797 4678409 | Office: +44 (0)114 2667712
<http://www.ardes.com/> | <http://blog.ardes.com/ian>

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
walt  
View profile
 More options May 2, 8:30 am
From: walt <walt...@diechmann.net>
Date: Fri, 2 May 2008 05:30:50 -0700 (PDT)
Local: Fri, May 2 2008 8:30 am
Subject: Re: newbee Q's - I'm afraid
Hi Ian,

my pleasure (and yours to be, I hope) :)

Well, that's just it - I thought, I'd read your docs carefully
through, and was expecting to get the ProjectsController#new method,
on my SmallProjectsController - but no!

It's probably the famous "comma" glitch that wreaked havoc on the
Apollo 11 ;)

Anyways, I've added my ProjectsController and SmallProjectsController
here - for everyone to "enjoy" (I mean, I'm so newbee on this rails
road) :))
- please correct me on the code in general, if you see "bad patterns"

class ProjectsController < ApplicationController #<
ResourceController::Base #

  # perhaps transform_with_xsl needs this one?
  require 'xml/xslt'

  before_filter :login_required
  after_filter :transform_with_xsl, :only => :display_invoice

  resources_controller_for :projects
  inherit_views

  def find_resources
    params[:perpage] ||= resource.per_page rescue
RECORDS_PER_PAGINATED_PAGE
    params[:page] ||= 1
    case params[:search]
    when nil
      resource_service.search("", params[:page], params[:perpage])
    else
      resource_service.search(params[:search], (params[:page] ),
( params[:perpage] ) )
    end
  end

  def new
    unless enclosing_resource.nil?
      @partner_name = enclosing_resource.name
      @contact = Contact.find_by_partner_id(enclosing_resource.id)
rescue "" #...@project.contact.name rescue ""
    else
      @partner_name = ""
      @contact = Contact.new
    end
    @new_contact_id = @contact.id rescue "0"
    @project = Project.new
    #...@project.project_number = @project.get_next_project_number
  end

  def edit
    @project = Project.find_by_id(params[:id])  or (render_404 and
return)
    @project.contact_name = @project.contact.name rescue ""
    @project.partner_name = @project.partner.name rescue ""
    #@contact = @project.contact rescue ""
    @new_contact_id = @project.contact.id rescue "0"
    @project.delivery_at_date = show_date @project.delivery_at
  end

  -------clipped to spare you the ugly details :) -------
end

class SmallProjectsController < ProjectsController
#ResourceController::Base
  before_filter :login_required

  resources_controller_for :small_projects

end

Ian, it really is very good of you to take your time answering my dumb
questions, especially when I know that you ought to be with your wife!

Thank you very much!
walt


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
walt  
View profile
 More options May 2, 9:44 am
From: walt <walt...@diechmann.net>
Date: Fri, 2 May 2008 06:44:24 -0700 (PDT)
Local: Fri, May 2 2008 9:44 am
Subject: Re: newbee Q's - I'm afraid

Hi Ian,

I forgot to attach the config/routes.rb (clipped to topic at hand)

  #map.resources :customers, :has_many =>
[ :projects, :small_projects, :invoices, :contacts]
  map.resources :customers do |customer|
    customer.resources :projects do |project|
      project.resources :tasks do |task|
        task.resources :jobs
      end
    end
    customer.resources :small_projects do |small_project|
      small_project.resources :tasks do |task|
        task.resources :jobs
      end
    end
    customer.resources :invoices do |invoice|
      invoice.resources :invoice_items
    end
    customer.resources :contacts
  end

As you might see from the above clipping, I've tried with
the :has_many way (it's Rails 2.0.2 - isn't it?) and with the :do way
(ol'school!?)

Cheers
walt


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian White  
View profile
 More options May 2, 9:46 am
From: "Ian White" <ian.w.wh...@gmail.com>
Date: Fri, 2 May 2008 14:46:42 +0100
Local: Fri, May 2 2008 9:46 am
Subject: Re: newbee Q's - I'm afraid
Hi walt,

You may have caught a bug (the inheritance issue)  I check the spec
suite and make sure

Do you have the latest rc and egde?  Or are you on 2.0.2

Cheers,
Ian

2008/5/2 walt <walt...@diechmann.net>:

--
Argument from Design--We build web applications
Western House 239 Western Road Sheffield S10 1LE UK
Mobile: +44 (0)797 4678409 | Office: +44 (0)114 2667712
<http://www.ardes.com/> | <http://blog.ardes.com/ian>

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
walt  
View profile
 More options May 2, 3:52 pm
From: walt <walt...@diechmann.net>
Date: Fri, 2 May 2008 12:52:01 -0700 (PDT)
Local: Fri, May 2 2008 3:52 pm
Subject: Re: newbee Q's - I'm afraid

Hi Ian,

I'm on 2.0.2  - but I've been looking for an opportunity to ask
someone for quite a while what their opinion towards edge is (for
buildings apps meant to be put into production). Do you develop RoR
apps on edge - and deploy them on edge as well?

I installed the r_c on April 30th

BTW: do you know of a rake tast that will show the (git) version of
plugins?

Hope not to have spoiled the entire r_c with my STI'ing ;)

cheers
Walt

ps sorry for not replying faster - I had to dance lancier with my
daughter who will graduate this summer :)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian White  
View profile
 More options May 2, 4:53 pm
From: "Ian White" <ian.w.wh...@gmail.com>
Date: Fri, 2 May 2008 21:53:08 +0100
Local: Fri, May 2 2008 4:53 pm
Subject: Re: newbee Q's - I'm afraid
Ok, you caught a bug (kinda) - thanks!
Basically, rc does lump in the rc actions over the top of what you;ve
already got

But a workaround is this (till it gets fixed)

(in subclassed controller, assuming that methods 'new', and 'create'
are defined in superclass, and you want them in the subclass)

class SmallProjectsController < ProjectsController
  resources_controller_for ...  , :except => [:new, :create]
end

Let me know how it works out

Cheers,
Ian

2008/5/2 walt <walt...@diechmann.net>:

--
Argument from Design--We build web applications
Western House 239 Western Road Sheffield S10 1LE UK
Mobile: +44 (0)797 4678409 | Office: +44 (0)114 2667712
<http://www.ardes.com/> | <http://blog.ardes.com/ian>

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
walt  
View profile
 More options May 2, 8:40 pm
From: walt <walt...@diechmann.net>
Date: Fri, 2 May 2008 17:40:13 -0700 (PDT)
Local: Fri, May 2 2008 8:40 pm
Subject: Re: newbee Q's - I'm afraid