rubyonrailsin

A Ruby and Rails talk

Friday, April 2, 2010

[Rails] Re: App_Controller and partial issues with has_many through

by rubyonrailsin 0 comments
When inspecting it I get [#,#,#,#] and my title reads "Your Interests
(4)" and the print out is
#
#
#
#

What is # all about? Is that an object filled with objects?


Colin Law wrote:
> On 2 April 2010 15:07, Jason Newport <lists@ruby-forum.com> wrote:
>> class ApplicationController < ActionController::Base
>> �end
>> � �<% @user_interests.each do |interest| -%>
>>
>> seems to be counting the number of posts on the specific pages (index or
>> show) and totaling those up as a users interests. �And if for one user I
>> add two interests and view the single post page then the title will read
>> "You have 3 interests", thus counts the two interests I really am
>> interested in plus the one for the Post page I am even though I have yet
>> to click/select it as an interest.
>
> I would suggest installing ruby-debug, then you can break into the
> controller or the view and inspect the variables and work out what is
> going wrong.
>
> See the rails guide on debugging at http://guides.rubyonrails.org/
>
> Colin

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

Read More…

[Rails] Re: Need help with find

by rubyonrailsin 0 comments
Finally figured out something that worked.

@club = Club.find(params[:club_id])
ids = @club.members.connection.select_values('SELECT person_id FROM
members')
@people = Person.all(:order => 'name_sort',
:conditions => ["id NOT IN (?)",
ids])

Any comments or better methods.

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

Read More…

[Rails] GurusQ: Metal calling disparity-How to install metal in code

by rubyonrailsin 0 comments
I have a simple class that I want to install as Rails Metal. I don't
want to put it into a file in app/metal for reasons I don't want to go
into. It looks like this, and handler is defined elsewhere.

class UrlFilter
ALLOW = [404]
DENY = [403]
def self.call(env)
handler.call(env["PATH_INFO"]) ? ALLOW : DENY
end
end

I've tried installing it like this :
ActionController::Dispatcher.middleware.use UrlFilter

but on the first request it crashes with :

Sat Apr 03 00:29:43 +0800 2010: Read error: #<ArgumentError: wrong
number of arguments (0 for 1)>
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/middleware_stack.rb:31:in
`call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/middleware_stack.rb:31:in
`klass'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/middleware_stack.rb:42:in
`active?'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/middleware_stack.rb:112:in
`active'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in
`find_all'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/middleware_stack.rb:112:in
`each'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/middleware_stack.rb:112:in
`find_all'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/middleware_stack.rb:112:in
`active'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/middleware_stack.rb:116:in
`build'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in
`build_middleware_stack'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:113:in
`call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/reloader.rb:34:in
`run'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in
`call'
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/rack/static.rb:31:in
`call'
/Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each'
/Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call'
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/rack/log_tailer.rb:17:in
`call'
/Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in
`call'
/Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/chunked.rb:15:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:64:in
`process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in
`process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in
`process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in
`initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in
`initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:34:in
`run'
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:111
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3

The rails calling code looks like this :

def klass
if @klass.respond_to?(:call)
@klass.call
elsif @klass.is_a?(Class)
@klass
else
@klass.to_s.constantize
end
rescue NameError
@klass
end

def active?
return false unless klass

if @conditional.respond_to?(:call)
@conditional.call
else
@conditional
end
end

Notice when calling call no arguments are passed (twice!) ? Every metal
example I've seen defines the entry method as

def self.call(env)

yet this calling code doesn't pass any.

Whats going on ? How do I define and install a metal class in code ?
--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] Re: Rails cascading delete

by rubyonrailsin 0 comments
Thanks all. Destroy worked great!,

Thanks
Hila;


On Apr 2, 2:41 am, Lasse Bunk <lasseb...@gmail.com> wrote:
> Hi Hilal,
>
> You need to use :dependent => :destroy instead of :delete_all because
> :delete_all doesn't fire any callbacks. That's why it only deletes one
> level.
>
> /Lasse
>
> 2010/4/2 Hilal <hilal.sha...@gmail.com>
>
> > Hello There:
> >    I am trying to do a deep cascading deletes in rails.
>
> > The schema looks like this:
>
> > Blogs (has many) entries ( has many ) comments
>
> > A blog has n entries, an entry has n comments.
>
> > So, in my Blog model I use
> > has_many :entries, :dependent => :delete_all
> > and in my Entry model I use
> > has_many :comments,:dependent => :delete_all
>
> >   The problem I am having is that deleting blogs, will only delete
> > entries, but will not delete comments. In other words, the cascading
> > delete isn't deep?
>
> >   Am I doing something wrong here?
>
> > Thanks
> > Hilal
>
> > --
> > 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-talk@googlegroups.com.
> > To unsubscribe from this group, send email to
> > rubyonrails-talk+unsubscribe@googlegroups.com<rubyonrails-talk%2Bunsubscribe@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/rubyonrails-talk?hl=en.

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

Read More…

[Rails] Using Builders

by rubyonrailsin 0 comments
I am using RoR 2.3, and have installed the builder gem

I have a line in a view as follows:

str_xml = render "fusioncharts/array_example/ss_array_data.builder",
{:arr_data => @arr_data}

Which does not set str_xml to anything.

I can confirm that in my controller I have @arr_data set up and
populated properly. (And in my controller, I have require 'builder'
at the top)

In my views folder, I have a folder set up under it as "fusioncharts/
array_example/" and the file ss_array_data.builder. (However, this may
be why str_xml is not being set -- when I go to the URL which would
invoke this view, I get "Missing template _ss_array_data.builder in
view path..." It will only render the page if I put the underscore
before the filename ss_array_data.builder, making it a partial).

What am I not understanding about builders that I cannot convert my
array @arr_data to str_xml ?

Thanks so much, RVince

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

Read More…

Re: [spree-user] Re: User Personalisation of Products

by rubyonrailsin 0 comments
A quick browse through your code shows that you can set options for a
product, but where were you planning on storing the information from
the user? I don't see any changes to the line_items table (or a
separate table), etc to store the personalization input from the user.

It also appears that each product can only have a single
personalization option. Is this your goal?

I have the need for something similar, but I need multiple
personalization options per product, and it needs to support more
options than a single text field (some "personalization" needs to be
radio buttons, select boxes, etc).

I would also merge your migrations right now while nobody is really
using the code. The way your migrations are currently written, if
someone was using a version that used the :personalisation_options
column inside products or variants, those changes would be lost when
you ran the 20100320220929_add_personalisable.rb migration since you
don't alter the name of the column, you drop it then re-create it. Of
course during the drop you lose any data that was entered by the admin
in that column. I assume that you are making the assumption that
nobody is using that previous version so it is ok to make the drop,
but if that's the case then you may as well clean up the migrations to
create the proper column to begin with. (Just my $0.02 on the
migrations)

-Chris

On Sat, Apr 3, 2010 at 6:24 AM, peachygifts <m.ward@leythers.com> wrote:
> The admin side of my extension is now working: an admin can set a
> product to be personalisable, and can then set personalisation options
> against a product.
>
> Now I would like to display these results of these options to
> customers:
>
> The product has a personalisable? attribute. The product may also have
> many personalisation_options associated with it. Each
> personalisation_option has name, title and max_length
>
> Step 1 now has me a little flummoxed: I need to build fields on the
> product page for each personalisation_option associated with a
> product, rendered as a label with title as its contents, and a text
> field that limits to the number of character specified in max_length.
>
> How do I go about this in spree / rails?
>
> For anyone interested in helping, the current extension can be found
> in its current gestation at git://github.com/peachygifts/spree-personalisation.git
>
> Thanks for your help!
>
> Michael
>
> --
> You received this message because you are subscribed to the Google Groups "Spree" group.
> To post to this group, send email to spree-user@googlegroups.com.
> To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.
>
>

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To post to this group, send email to spree-user@googlegroups.com.
To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Read More…

[Rails] Re: Best way of sorting/grouping objects

by rubyonrailsin 0 comments
By any chance do you have a model named PageType? If you, you could
set up a relationship between PageType and Page:

page.rb:
belongs_to :page_type

page_type.rb:
has_many :pages

Then display it with:

your_controller.rb:
@page_types = PageType.all

your_view.html.haml (or .erb, etc.)
- @page_types.each do |page_type|
%h1= page_type.name
%ul
= list_of page_type.pages do |page|
= page.name

If you don't already have a PageType model, or don't want to introduce
another model, you could probably use:

@page_types = Page.all(:order => 'page_type', :group => 'page_type')

and then play around with the result of that. (At least I think that's
correct… haha, sorry if it's not)

Good luck,
Angelo

On Apr 2, 7:31 am, Brent <wejrow...@gmail.com> wrote:
> That could work. But I need it to order by page_order also.  I would
> like to group them into 3 groups then sort them by that. In the end I
> want it to look something like this in html...
>
> TYPE ONE
> Page 1
> Page 2
>
> TYPE TWO
> Page 1
> Page 2
>
> Before I was doing something like this (I had an array of each page
> type called page_types):
>
> <% page_types.each do |t| %>
>     <%= t %>'s
>    <% Page.find(:all, :conditions=>{:page_type=>t}, :order=>position
> %>
>      etc.
>   <% end %>
> <% end %>

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

Read More…

[Rails] Re: "new" form as partial?

by rubyonrailsin 0 comments
On Apr 2, 4:27 pm, Marian Steinbach <marian.steinb...@gmail.com>
wrote:

> Creating a certain type of database record is a very frequent task in
> my application (or at least it should be ;-)). So I want to be able to
> place the form for creating that database record in practically any
> view, not just the /mymodel/new view.

I'm sure you can refactor code to fit almost anything into a single
new/edit partial :) But in my small experience the models are
different enough so that having different views for different models
makes the code more readable. That said, I almost always share new
and edit for a model in a partial:

e.g. new.html.erb
<%= render( :partial => "form", :locals => { :buttonname => 'Add' } )
%>

edit.html.erb
<%= render( :partial => "form", :locals => { :buttonname =>
'Update' } ) %>

_form.html.erb
<%= error_message_on :lab, :base %>
<% form_for ..., do |f| %>
<%= f.submit buttonname %>
...
<% end %>

Ryan Bates has great screencasts on this sort of thing, and I found
his Mastering Rails Forms http://www.pragprog.com/screencasts/v-rbforms/mastering-rails-forms
($5 a video) to be a great start.

Craig

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

Read More…

[Rails] Re: ScrAPI HTTPNoAccessError

by rubyonrailsin 0 comments
I should also add -

Before I got the findurl method to just strip out any URLs with non
standard characters, I tried this line:

fullurl.gsub!(",","%2C")

Which replaced the commas with the URL friendlier code. This didn't work
either, nor did putting the whole lot inside a CGI.escape("")

The scrAPI documentation isn't particularly helpful in regards to what
format the URL needs to be in.
--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] Re: Weird date/time incompatibility

by rubyonrailsin 0 comments
On Apr 2, 6:05 pm, Craig White <craigwh...@azapple.com> wrote:

> they actually are in sync
>
> Fri Apr  2 17:13:05 CDT 2010 == 2010-04-02 22:13:05 (UTC) as CDT is UTC
> + 5 hours

Sorry for my sloppiness--I understand. I guess my main question is why
would it show the correct time in the view on one machine, but not
another?

datetime.strftime("%A %B %d %Y %I:%M:%S %p")

Is different for each machine. I'm busily writing code to detect
where the user is, and adjusting the time shown in the view
accordingly, but I'm still mildly confused by why the two views show
differently.

Thanks,
Craig

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

Read More…

[Rails] ScrAPI HTTPNoAccessError

by rubyonrailsin 0 comments
Hi,

I'm having some problems using scrAPI. I'm getting some
HTTPNoAccessErrors on certain urls.

The program searches a page (http://en.wikiquote.org/wiki/List_of_films)
for all of the links on it that go to pages with movie quotes on them.

It then loops through the list, pulling out the details from each page
using this method:

def self.scrapemovies
Scraper::Base.parser :html_parser

urlarray = Movie.findurls

moviescraper = Scraper.define do
process "h1", :name => :text
process "p:nth-child(4)", :description => :text
result :description, :name
end

urlarray.each do |url|
fullurl = "http://en.wikiquote.org#{url}"
movieurl = URI.parse(fullurl)
data = moviescraper.scrape(movieurl)
movie = Movie.new
movie.url = fullurl
movie.name = data.name
movie.description = data.description
movie.save
end
end


This worked ok until it got to
http://en.wikiquote.org/wiki/20,000_Leagues_Under_the_Sea which gave me
the http error because it had a comma in the URL.

I wrote a little bit of code in the Movie.findurl method that just
stripped out any URLs with commas or parentheses in as a bodge just to
get things working, but I'm even getting the error on this URL:
http://en.wikiquote.org/wiki/27_Dresses which is very odd, because it
worked fine on the previous one which was :
http://en.wikiquote.org/wiki/25th_Hour.

I can't see the difference between them - I've tried manually visiting
the page, and it's fine.

I'm assuming that I need to do some sort of cleverer parsing on the URLs
(so that I can include the ones with commas and parentheses too).

Is the Scraper::Base.parser :html_parser line got anything to do with
it? I couldn't get the Tidy plugin to work properly, but I'm not sure
that it's got anything to do with the URL parsing anyway.

I'm totally stuck - thanks in advance for any help.

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

Read More…

Re: [Rails] Re: Weird date/time incompatibility

by rubyonrailsin 0 comments
On Fri, 2010-04-02 at 15:28 -0700, Dudebot wrote:
>
> On Apr 2, 3:12 pm, Colin Law <clan...@googlemail.com> wrote:
>
> > Am I right in assuming that is what is contained in the <a href link
> > in the html? If so then the first thing is that they are in different
> > timezones. Can you confirm that you are definitely seeing the above
> > dates with the same version of the code. You said you had been
>
> ...
> > Do you want to see a local time there or UTC?
>
> Thanks again--the difference was that I had this in the development
> config/enviroment.rb
> config.time_zone = 'UTC'
> But not in the production file. I uncommented it in the production
> environment.rb just now, and lo and behold, that part is now working.
>
> Except--I now remember I had in commented out of the production server
> as another part of the code which displays the "created at" field for
> a record was giving the wrong time. E.g. if I run date in a terminal
>
> I get Fri Apr 2 17:13:05 CDT 2010
>
> (Which is my time)
> But for the created at for this record in the database I'm getting
>
> 2010-04-02 22:13:33
>
> I don't seem to have that problem on my development machine (MacOS
> laptop). The production server is a Redhat Linux machine.
>
> Any idea how to "sync" created at and the system time on the
> production server?
>
> Again, many TIA,
> Craig
----
they actually are in sync

Fri Apr 2 17:13:05 CDT 2010 == 2010-04-02 22:13:05 (UTC) as CDT is UTC
+ 5 hours

Craig


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

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

Read More…

[Rails] Re: HAS_MANY BELONGS_TO noobie question

by rubyonrailsin 0 comments
bump... :) i really need help guys.

On Apr 2, 12:39 pm, David Zhu <dzwestwindso...@gmail.com> wrote:
> Oh, thanks that relaly helped, but one more thing-
>
> If i assigned posts to anotherposts, through a has_many :anotherposts
> and belongs_to :posts relationship, how would i do @post =
> current_user.posts.build(params[:post]) in this situation? Because i
> dont have the current_user helper anymore, because we are not dealing
> with users, but with the post that i want to create anotherposts ontop
> of.
>
> so basically instead of the current_user helper, i want to use the
> post that the anotherposts is being created on.
>
> Do you understand? Hit me with more questions if you want :)
>
> I really need help, this shouldn't be difficult at all. Just a minor
> switch, that i can't get my mind around. Hope you can help! thanks!!
>
> On Mar 27, 10:26 am, Lasse Bunk <lasseb...@gmail.com> wrote:
>
> > HeyDavid,
>
> > It's really pretty easy and straightforward.
> > In your PostsController:
>
> >   def create
> >     @post = current_user.posts.build(params[:post])
> >     if @post.save
> >       # ...
> >     else
> >       # ...
> >     end
> >   end
>
> > Also in your PostsController, to list posts only from current_user:
>
> >   def index
> >     @posts = current_user.posts
> >   end
>
> > If you want your show method to only look for posts from current_user:
>
> >   def show
> >     @post = current_user.posts.find(params[:id])
> >   end
>
> > /Lasse
>
> > 2010/3/27DavidZhu<dzwestwindso...@gmail.com>
>
> > > Hey,
>
> > > I made my authentication system using Authlogic, and I have a
> > > current_user helper
>
> > > Now, I also made a scaffold called posts, and everytime a user creates
> > > a post using that scaffold, i want it to be assigned to that
> > > particular user.
>
> > > So i can render out the posts that ONLY that user made.
>
> > > Now, the question is what to do in the forms, and what to do in the
> > > posts controller.
>
> > > Right now, I already have a has_many belongs_to relationship between
> > > the too, but i dont know where to go next. What do i have to chnage in
> > > the posts controller? What is my post form supposed to look like in
> > > order for it to be associated with the current_user?
>
> > > AWww ive been trying to get my mind around this, but i can't. i need
> > > help. really bad.
>
> > > Someone please help. please!!
>
> > > --
> > > 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-talk@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > rubyonrails-talk+unsubscribe@googlegroups.com<rubyonrails-talk%2Bunsubscribe@googlegroups.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/rubyonrails-talk?hl=en.

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

Read More…

[Rails] Re: Rails model design visualization

by rubyonrailsin 0 comments
On Apr 2, 3:49 pm, "Joe Smith" <unknown_kev_...@hotmail.com> wrote:

> In addition to railroads, The rubymine IDE has a visualization system. Uses
> the (proreitary) yFiles Graph visualization library, so the images look a
> little fancier, but the basic graphs are not too disimilar.

Thanks, Joe! I'll have to check it out... Looks like us poor
academics are given a break on the price :)
Craig

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

Read More…

[Rails] Re: Weird date/time incompatibility

by rubyonrailsin 0 comments
On Apr 2, 3:12 pm, Colin Law <clan...@googlemail.com> wrote:

> Am I right in assuming that is what is contained in the <a href link
> in the html?  If so then the first thing is that they are in different
> timezones.  Can you confirm that you are definitely seeing the above
> dates with the same version of the code.  You said you had been

...
> Do you want to see a local time there or UTC?

Thanks again--the difference was that I had this in the development
config/enviroment.rb
config.time_zone = 'UTC'
But not in the production file. I uncommented it in the production
environment.rb just now, and lo and behold, that part is now working.

Except--I now remember I had in commented out of the production server
as another part of the code which displays the "created at" field for
a record was giving the wrong time. E.g. if I run date in a terminal

I get Fri Apr 2 17:13:05 CDT 2010

(Which is my time)
But for the created at for this record in the database I'm getting

2010-04-02 22:13:33

I don't seem to have that problem on my development machine (MacOS
laptop). The production server is a Redhat Linux machine.

Any idea how to "sync" created at and the system time on the
production server?

Again, many TIA,
Craig

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

Read More…

[Rails] HELP!! Rake aborted! Can't modify frozen hash

by rubyonrailsin 0 comments
Too bad even the trace doesn't say which hash is involved.

Sorry this post is long: am trying to provide enough context to be
meaningful.

Occurs _intermittently_ when rake jobs:work is pulling a command out of
delayed_jobs while my status observer is in the process of parsing a log
file for detailed results of the previous delayed_job denizen. I have
an observer class (in RAILS_ROOT/lib ) which listens for the events,
makes a copy of them and calls the owner class ( in apps/models ) which
then calls on the log parser (also in /lib) to do the actual work.
(Should both of those classes, the observer and the parser be in
app/models?)

Am due to deliver this application in a few days and this is killing it
(and me).

Am using DirectoryWatcher to look for flag files that indicate the start
and finish of the delayed_jobs.
That is started at the end of environment.rb like this:

require 'directory_watcher'
$scriptStatusObserver = ScriptStatusObserver.new
dirToWatch ="#{RAILS_ROOT}/tmp/flags"
$directoryWatcher = DirectoryWatcher.new( dirToWatch )
$directoryWatcher.glob= "*.flg"
$directoryWatcher.interval=(15)
$directoryWatcher.add_observer( $scriptStatusObserver )
$directoryWatcher.persist=("#{RAILS_ROOT}/tmp/flags/dw_state.yml")
$directoryWatcher.start

at_exit { $directoryWatcher.stop }

This code is outside of the run method (btw is that the best place or is
inside the run better?)

Here is the observer:
require 'script_run'

class ScriptStatusObserver

def initialize
@rcvdEvents = []
end

def update( *events )
begin
puts "#{__LINE__.to_s}: ScriptStatusObserver events:
\n"+events.to_yaml
cnt = 0

events.each do |e|
if e.to_s.match(/^\s*added/)
cnt = cnt + 1
@rcvdEvents << e
end
end

ScriptRun.new.catch_up( @rcvdEvents ) if cnt > 0

@rcvdEvents.clear

rescue
puts $!
end

end
end

Here is ScriptRun (it attaches to an associative table built with
has_many:through)

#require 'observer'

class ScriptRun < ActiveRecord::Base

set_table_name "scripts_runs"
belongs_to :script
belongs_to :run

def parse( result )
parser = LogParser.new
parser.parse(result)
end

def catch_up( events )
events.each do |e|
typ = e.type
path = e.path

thisMatch = path.match(/flags\/(\d+)_(\d+)_([\d\.]+)_(\w+)\.flg/)
run_id = thisMatch[1]
script_id = thisMatch[2]
ts = thisMatch[3]
status = thisMatch[4]

if e.to_s.match(/^\s*added/)
status_update( script_id, run_id, status, ts, path )
end
end
end

def status_update( script_id, run_id, status, ts, path )

scriptrun = ScriptRun.find(:first, :conditions => [ "run_id = ? and
script_id = ?", run_id.to_i, script_id.to_i ])

if scriptrun.kind_of?(ScriptRun)
currStatus = scriptrun.status
if not currStatus == 'completed'

scriptrun.update_attribute(:status, status)

if status == 'parse'
flag = File.new(path)
logSpec = flag.gets
flag.close

logName = File.basename(logSpec)
logPath = logSpec.sub(logName, '')

logName =~ /^(([\w_]+)_([\w]+)_(\d+))\.log$/
name = $1
basename = $2
runenv = $3
tsOrPid = $4

result = Result.new
result.log_path = logPath
result.basename = basename
result.name = name
result.script_id = script_id.to_i
result.run_id = run_id.to_i
if runenv == 'sit'
runenv = 'SIT3348'
end
result.application_environment_id =
ApplicationEnvironment.find(:first, :conditions => [
"nodename = ?", runenv]).id

parse(result)

if run_completed?( run_id )
myRun = Run.find(run_id.to_i)
if myRun.kind_of?( Run )
myRun.update_attribute( :completed, Time.now.to_f )
end
end

end
end

else
puts "#{__LINE__.to_s}: ScriptRun.status_update: ScriptRun not
found for run #{run_id} script #{script_id} ts #{ts.to_s}"
end

File.delete(path)

end

def run_completed?( id )
scriptruns = ScriptRun.find(:all, :conditions => [ "run_id = ?",
id.to_i] )
scriptruns.each do |sr|
if not sr.status == 'completed'
return false
end
end
return true
end
end

LogParser is too long even for this post but it reads the script log and
pulls detailed information (counts and timings) out of the log and
writes to a details table. It also tallies and calculates averages and
rolls those up into summary tables for quicker access from the web
pages.

Here is the error trace:
(don't ask why everything is under my Windows profile. It's a long
story)

Scanner running 1270239731.43
directory_watcher.notify_observers: #<ScriptStatusObserver:0x48ae838
@rcvdEvents
=[#<struct DirectoryWatcher::Event type=:added, path="C:/Documents and
Settings/
pneve/workspace/waftt-0.29/tmp/flags/100039_11_1270236464.921_parse.flg">,
#<str
uct DirectoryWatcher::Event type=:added, path="C:/Documents and
Settings/pneve/w
orkspace/waftt-0.29/tmp/flags/100039_18_1270239550.108_parse.flg">]>
update:[#<struct DirectoryWatcher::Event type=:added, path="C:/Documents
and Set
tings/pneve/workspace/waftt-0.29/tmp/flags/100039_19_1270239727.368_parse.flg">,
#<struct DirectoryWatcher::Event type=:removed, path="C:/Documents and
Settings
/pneve/workspace/waftt-0.29/tmp/flags/100039_18_1270239550.108_parse.flg">]
rake aborted!
can't modify frozen hash
C:/Documents and
Settings/pneve/workspace/waftt-0.29/vendor/rails/activerecord/l
ib/active_record/attribute_methods.rb:313:in `[]='
C:/Documents and
Settings/pneve/workspace/waftt-0.29/vendor/rails/activerecord/l
ib/active_record/attribute_methods.rb:313:in
`write_attribute_without_dirty'
C:/Documents and
Settings/pneve/workspace/waftt-0.29/vendor/rails/activerecord/l
ib/active_record/dirty.rb:139:in `write_attribute'
C:/Documents and
Settings/pneve/workspace/waftt-0.29/vendor/rails/activerecord/l
ib/active_record/attribute_methods.rb:211:in `last_error='
C:/Documents and
Settings/pneve/workspace/waftt-0.29/vendor/plugins/delayed_job/
lib/delayed/worker.rb:141:in `handle_failed_job'
C:/Documents and
Settings/pneve/workspace/waftt-0.29/vendor/plugins/delayed_job/
lib/delayed/worker.rb:115:in `run'
C:/Documents and
Settings/pneve/workspace/waftt-0.29/vendor/plugins/delayed_job/
lib/delayed/worker.rb:162:in `reserve_and_run_one_job'
C:/Documents and
Settings/pneve/workspace/waftt-0.29/vendor/plugins/delayed_job/
lib/delayed/worker.rb:92:in `work_off'
C:/Documents and
Settings/pneve/workspace/waftt-0.29/vendor/plugins/delayed_job/
lib/delayed/worker.rb:91:in `times'
C:/Documents and
Settings/pneve/workspace/waftt-0.29/vendor/plugins/delayed_job/
lib/delayed/worker.rb:91:in `work_off'
C:/Documents and
Settings/pneve/workspace/waftt-0.29/vendor/plugins/delayed_job/
lib/delayed/worker.rb:66:in `start'
C:/Documents and
Settings/pneve/workspace/waftt-0.29/vendor/rails/activesupport/
lib/active_support/core_ext/benchmark.rb:10:in `realtime'
C:/Documents and
Settings/pneve/workspace/waftt-0.29/vendor/plugins/delayed_job/
lib/delayed/worker.rb:65:in `start'
C:/Documents and
Settings/pneve/workspace/waftt-0.29/vendor/plugins/delayed_job/
lib/delayed/worker.rb:62:in `loop'
C:/Documents and
Settings/pneve/workspace/waftt-0.29/vendor/plugins/delayed_job/
lib/delayed/worker.rb:62:in `start'
C:/Documents and
Settings/pneve/workspace/waftt-0.29/vendor/plugins/delayed_job/
lib/delayed/tasks.rb:13
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.
rb:636:in `call'
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.
rb:636:in `execute'
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.
rb:631:in `each'
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.
rb:631:in `execute'
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.
rb:597:in `invoke_with_call_chain'
c:/Documents and Settings/pneve/ruby/lib/ruby/1.8/monitor.rb:242:in
`synchronize
'
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.
rb:590:in `invoke_with_call_chain'
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.
rb:583:in `invoke'
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.
rb:2051:in `invoke_task'
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.
rb:2029:in `top_level'
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.
rb:2029:in `each'
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.
rb:2029:in `top_level'
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.
rb:2068:in `standard_exception_handling'
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.
rb:2023:in `top_level'
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.
rb:2001:in `run'
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.
rb:2068:in `standard_exception_handling'
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.
rb:1998:in `run'
c:/Documents and
Settings/pneve/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:
31
c:/Documents and Settings/pneve/ruby/bin/rake:16:in `load'
c:/Documents and Settings/pneve/ruby/bin/rake:16
--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] Re: Trying to create search filter persistence using SearchLogic

by rubyonrailsin 0 comments
Patrick Shainin wrote:
>
> For example, to add a check box that limits the search to rows with a
> certain condition, you could define a named scope in Model.rb like this:
>
> named_scope :my_condition, :conditions => "your sql condition here"
>
> Then in the view form, you would include:
> &lt;%= f.label :my_condition, "Check to apply my condition" %&gt;
> &lt;%= f.check_box :my_condition %&gt;

I forgot that f.check_box adds a hidden field so even unchecked, the
condition will trigger. One way to get around that is to use lambda in
the named scope and adjust what condition gets included based on the
check box value:

named_scope :my_condition, lambda { |check| "1"==check ? {:conditions=>
"your sql condition here"} : {}}
--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] "new" form as partial?

by rubyonrailsin 0 comments
Hi!

I think I'm trying to accomplish something very common, but I can't
find a way to do it.

Creating a certain type of database record is a very frequent task in
my application (or at least it should be ;-)). So I want to be able to
place the form for creating that database record in practically any
view, not just the /mymodel/new view.

I figured that this might be done using a partial, but since I'm
pretty new to rails, I don't get it one.

Can anybody point me to a tutorial for this problem?

I'm using rails 2.3.5.

Thank you!
Marian

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

Read More…

[spree-user] Re: User Personalisation of Products

by rubyonrailsin 0 comments
The admin side of my extension is now working: an admin can set a
product to be personalisable, and can then set personalisation options
against a product.

Now I would like to display these results of these options to
customers:

The product has a personalisable? attribute. The product may also have
many personalisation_options associated with it. Each
personalisation_option has name, title and max_length

Step 1 now has me a little flummoxed: I need to build fields on the
product page for each personalisation_option associated with a
product, rendered as a label with title as its contents, and a text
field that limits to the number of character specified in max_length.

How do I go about this in spree / rails?

For anyone interested in helping, the current extension can be found
in its current gestation at git://github.com/peachygifts/spree-personalisation.git

Thanks for your help!

Michael

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To post to this group, send email to spree-user@googlegroups.com.
To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Read More…

Re: [Rails] Re: Rails model design visualization

by rubyonrailsin 0 comments
>> Railroad does this (after a fashion) http://railroad.rubyforge.org/
>
> So that rocks. When did the world get so ultra cool? *Many, many*
> thanks.

plus one from me! Thank you very much!

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

Read More…

Re: [Rails] Re: Rails model design visualization

by rubyonrailsin 0 comments
>> Railroad does this (after a fashion) http://railroad.rubyforge.org/
>
> So that rocks.  When did the world get so ultra cool?  *Many, many*
> thanks.

plus one from me! Thank you very much!

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

Read More…

[Rails] Re: Two controllers with create using the same model

by rubyonrailsin 0 comments
Thanks a lot Colin,

First of all, I'm using Rails 2.3.5. and Ruby 1.8.7.
The generated HTML looks like this: <form method="post"
id="beiratkozok" action="/beiratkozas">
The option suggested by you: <% form_for :student, @student, :url =>
{:controller => 'beiratkozas', :action => "create" }, :html =>
{ :method => :post, :id => "beiratkozok" } do |f| %> gives the very
same result, so somehow the form_for assumes that controller is
'beiratkozas'. Maybe because the path is: Views/beiratkozas/
new.html.erb to the view that contains the form_for.

And works, since I have:

map.connect 'beiratkozok', :controller => 'beiratkozas', :action =>
'new'
map.connect 'hallgato/:id', :controller => 'beiratkozas', :action =>
'show'
map.connect 'beiratkozas', :controller => 'beiratkozas', :action =>
'create'

I know that map.resources :beiratkozas would be a more Rails like
approach, but it's more human readable for Hungarians if I use
meaningful Hungarian words.

The html is added since I need the ID for CSS, and I wanted a
meaningful word as ID, since it makes CSS easier to read. On the other
hand :method => :post was added since I saw something like that
somewhere, and it made sense, since I want to use the POST verb in
this case. Right?

Peter

P.S.: What do you mean putting my comments inline with the previous
post? I'm simply hitting reply.

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

Read More…

Re: [Radiant-Dev] [ANN] PageFactory extension

by rubyonrailsin 0 comments
>>> On a side note, another thing I realized is that there should be
>>> some
>>> description for the available templates.
>>
>> This would be nice. Do we have an existing UI pattern for a modal
>> containing
>> a table instead of a select element?
>
> I don't believe we do.

OK. I'll put something basic together and someone who knows pixels can
sort it out.

On Apr 2, 2010, at 3:41 PM, Jim Gay wrote:

> On Fri, Apr 2, 2010 at 3:01 PM, Josh French <josh@digitalpulp.com>
> wrote:
>> If the above method is available to the controller/view, then it
>> already has
>> access to the @page instance and current user, plus anything else I
>> can find
>> in the current request.
>>
>> On the other hand, Page#factories(current_user=nil) implies there's
>> only one
>> dimension you can filter on. It makes it harder for extensions
>> which might
>> want to filter by something we haven't thought of yet.
>
> Good point.
>
>>
>>> On a side note, another thing I realized is that there should be
>>> some
>>> description for the available templates.
>>
>> This would be nice. Do we have an existing UI pattern for a modal
>> containing
>> a table instead of a select element?
>
> I don't believe we do.
>
> --
> Jim Gay
> http://www.saturnflyer.com
>
> --
> Radiant CMS Dev Mailing List
> Post: radiantcms-dev@googlegroups.com
> Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
> Group Site: http://groups.google.com/group/radiantcms-dev/

--
Radiant CMS Dev Mailing List
Post: radiantcms-dev@googlegroups.com
Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
Group Site: http://groups.google.com/group/radiantcms-dev/

To unsubscribe, reply using "remove me" as the subject.

Read More…

[Rails] Re: Trying to create search filter persistence using SearchLogic

by rubyonrailsin 0 comments
dburges wrote:
> I have just set up a search form on my index using SearchLogic- it
> works great. However, since there are several search parameters in the
> form I want the results of the most recent search to remain in effect
> until the user does a new search. I can't figure out how to do this!
> I've tried a few things with global and session variables but just
> can't get it working.
>
> Any advice would be greatly appreciated!

The previous form values you want for re-initializing the form are
passed into your controller method in the params object. If you have
built your form around an object called @search like this:

form_for @search do |f|

you just need to initialize @search with the search values in params, in
the controller method (perhaps Controller#index), like this:

@search = Model.search(params[:search])

If you have fields that are not part of Model that you want to include
in the search and have those initialized to, define a named_scope in
Model, and use that named_scope in the form for @search. Then it will
also be part of the params search values and get initialized along with
the other, automatically generated named scopes that correspond to the
model fields.

For example, to add a check box that limits the search to rows with a
certain condition, you could define a named scope in Model.rb like this:

named_scope :my_condition, :conditions => "your sql condition here"

Then in the view form, you would include:
&lt;%= f.label :my_condition, "Check to apply my condition" %&gt;
&lt;%= f.check_box :my_condition %&gt;
--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

Re: [Rails] http://api.rubyonrails.org/ not working!!

by rubyonrailsin 0 comments
On Fri, Apr 2, 2010 at 8:57 PM, rorguy <amanbop@gmail.com> wrote:

> Not sure if anyone else has looked at it, but I have been seeing this
> for about a week now. The link "Rails: Complete API" on Documentaion
> page on http://rubyonrails.org/documentation is not working. It fails
> with following error:
>
> Precondition Failed
> The precondition on the request for the URL /index.php evaluated to
> false.

This happens sometimes in my place. Looks like it may be some
country-level proxy in Spain or something according to some people.
The site is up.

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

Read More…

[Rails] Re: http://api.rubyonrails.org/ not working!!

by rubyonrailsin 0 comments
On Apr 2, 9:55 pm, Greg Donald <gdon...@gmail.com> wrote:
> On Fri, Apr 2, 2010 at 12:57 PM, rorguy <aman...@gmail.com> wrote:
> > Not sure if anyone else has looked at it, but I have been seeing this
> > for about a week now. The link "Rails: Complete API" on Documentaion
> > page onhttp://rubyonrails.org/documentationis not working. It fails
> > with following error:
>
> > Precondition Failed
> > The precondition on the request for the URL /index.php evaluated to
> > false.
>
> Works for me.
>
And me. It's also worth noting that you can generate those docs from
any rails app - just run rake doc:rails

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

Read More…

[Rails] Re: please help; form_for passes nil

by rubyonrailsin 0 comments
On Apr 2, 6:23 pm, dirtbug <nyoun...@gmail.com> wrote:
> I have an update button that doesn't update.  Watching the server
> during the attempt, I see:
>
> Processing OrvesController#update (for 128.119.60.171 at 2010-04-02
> 13:13:29) [PUT]
>   Parameters: {"orf"=>nil, "commit"=>"Update", "id"=>"19544"}
>
> orf is my model I'm trying to update in the database.  Why is it nil?
>
It's probably worth taking a look at the raw data posted by the
browser - if it is malformed in some way that could be causing rails
to parse it in a funny way. It probably doesn't help that your html is
malformed (a td must be contained in a tr or similar, i'm pretty sure
you can't stick a form in a table like that and the button_to will
create a second form (ie you'll have a form nested in another form)

Fred
> The view for the page with the update button is called edit.html.erb
> and contains:
>
> <h1>Editing orf</h1>
> <table>
>         <% form_for @orf do |f| %></td>
>           <td><%= f.error_messages %>
>           <td><%= h @orf.locus_tag %></td>
>           <td><%= f.text_field 'current_annotation', :size => 50  %></td>
>                 <td><%= f.submit "Update" %></td>
>                 <td><%= button_to "Undo last change", :action
> => :undo_last_change, :id => @orf %></td>
>         <% end %>
>
> orf's attributes locus_tag and current_annotation are being correctly
> displayed.
>
> Here's the update method:
>
>   def update
>     @orf = Orf.find(params[:id])
>     if @orf.update_attributes(params[:orf])
>       flash[:notice] = 'Orf was successfully updated.'
>       redirect_to orf_path
>     else
>       flash[:notice] = 'Update failed.'
>       redirect_to orf_path
>     end
>   end
>
> routes.rb contains the line:
>   map.resources :orves
>
> No error message appears in the web browser.  The update just doesn't
> change anything.
>
> I'm running Rails 2.3.0.
>
> Any idea what I'm doing wrong?

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

Read More…

Re: [Rails] http://api.rubyonrails.org/ not working!!

by rubyonrailsin 0 comments
On Fri, Apr 2, 2010 at 12:57 PM, rorguy <amanbop@gmail.com> wrote:
> Not sure if anyone else has looked at it, but I have been seeing this
> for about a week now. The link "Rails: Complete API" on Documentaion
> page on http://rubyonrails.org/documentation is not working. It fails
> with following error:
>
> Precondition Failed
> The precondition on the request for the URL /index.php evaluated to
> false.


Works for me.


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

Read More…

[Rails] Re: Rails model design visualization

by rubyonrailsin 0 comments
"Dudebot" <craignied@gmail.com> wrote in
message
news:f2c00b23-cb4a-4b09-9325-d2c64c3a44e4@w17g2000yqj.googlegroups.com...
> I'm a fairly visual person, and I have a piece of paper with many
> boxes and arrows with labels like "has many" and "belongs to" for my
> database models. It's messy, but it works.
>
> What I keep looking for--weeks, actually, I'm certain it's out there,
> but I haven't hit on the right set of Google query terms :)--is
> something that will take a Rails set of models and show its design.
>
> Does anyone know of such a thing? And if not, what are people using
> to visually lay out their model designs?

In addition to railroads, The rubymine IDE has a visualization system. Uses
the (proreitary) yFiles Graph visualization library, so the images look a
little fancier, but the basic graphs are not too disimilar.

One nice feature is that it is live unlike railroads, alowing you to move
around the models if you did not like the default layout. It also lets you
show/hide the special properties of a model like 'Created_at', as well as
show or hide the user defined models.

Probably not worth considering unless you already use the Rubymine IDE, but
I thought it should be thrown out there.


Now for an aside:
I know IDE's are not particularly popular in the Rails community, and for
good reason. Most IDEs are fairly bloated, and often make some tasks harder.
Depite being a java-based IDE it is not as bloated as say an Eclipse-based
IDE. The IDE though is suprising good at offering good options for
autocomplete, although not perfect, but with a dynamically typed language
perfect is just not possible. Unfortunately, in a few places the Rubymine
IDE does make some tasks harder. An example is not being able to just type
"rake db:migrate" but having to use a keystoke combination to open a dialog
box to choose which version to migrate the database to.

Perhaps a furtue version will offer a command prompt for those who like the
code completion, refactoring helpers, and some of the other little nice
touches an IDE can offer[1], but want to keep the existing command line
workflows. I know the latest private beta of RadRails is offering this.

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

Read More…

Re: [Rails] Re: Two controllers with create using the same model

by rubyonrailsin 0 comments
On 2 April 2010 21:21, WSzP <ctdd@ctdd.ro> wrote:
> Thanks a lot Colin, that was my problem.
>
> From documentation I managed to make a working form_for:
>
> <% form_for :student, @student, :url => { :action => "create" }, :html
> => { :method => :post, :id => "beiratkozok" }   do |f| %>
>
> This works, but I don't understand why do I need the :student in the
> front. What does it do?

It is in the docs, the :student says that the object being displayed
and submitted is of type student, the @student is the variable
containing the student. In fact since these are the same word you do
not need both, either :student or @student will work I think, though
using @student is more usual I think. Having both allows the class
name and variable to be different.

I don't know why you have the html options they should not be needed.

I also don't understand why this is going to the beiratkozas
controller, I would have expected it to go to the students controller.
I would have expected you to put :url => { :controller =>
'beiratkozas', :action => "create" } to send it to that controller.
Check the html of the page (View, Page Source or similar in browser).

By the way it may be a good idea to put your comments inline with the
previous posts as it is then easier to follow the thread.

Colin

>
> On Apr 2, 11:18 pm, Colin Law <clan...@googlemail.com> wrote:
>> On 2 April 2010 21:00, WSzP <c...@ctdd.ro> wrote:
>>
>> > You got me wrong. I can't put the create method in the student
>> > controller.
>> > The question if, how could I use the create method from the
>> > BeiratkozasController class, while the model is NOT Beiratkozas, but
>> > Student.
>>
>> Have a look at the docs for form_for, you will see it has a url
>> parameter which will allow you to specify the controller and action
>> that you wish to be performed on the submit.
>>
>> Colin
>
> --
> 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-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

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

Read More…

[Rails] Re: Two controllers with create using the same model

by rubyonrailsin 0 comments
Thanks a lot Colin, that was my problem.

From documentation I managed to make a working form_for:

<% form_for :student, @student, :url => { :action => "create" }, :html
=> { :method => :post, :id => "beiratkozok" } do |f| %>

This works, but I don't understand why do I need the :student in the
front. What does it do?

On Apr 2, 11:18 pm, Colin Law <clan...@googlemail.com> wrote:
> On 2 April 2010 21:00, WSzP <c...@ctdd.ro> wrote:
>
> > You got me wrong. I can't put the create method in the student
> > controller.
> > The question if, how could I use the create method from the
> > BeiratkozasController class, while the model is NOT Beiratkozas, but
> > Student.
>
> Have a look at the docs for form_for, you will see it has a url
> parameter which will allow you to specify the controller and action
> that you wish to be performed on the submit.
>
> Colin

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

Read More…

[Rails] Re: Two controllers with create using the same model

by rubyonrailsin 0 comments
On Apr 2, 3:45 pm, DmitryPush <dmitryp...@gmail.com> wrote:
> so now we can see exactly what rails told you - it is now create
> method in student controller. :)
> and why you view requesting student controller i already told you.
> :)
>
> On Apr 2, 4:39 pm, WSzP <c...@ctdd.ro> wrote:
>
> > Hello,
> > Thanks a lot, and here is my students_controller.rb:http://pastie.org/900218
> > So I had one, but forgot to paste it to pastie.
> > Peter

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

Read More…

Re: [Rails] Re: Two controllers with create using the same model

by rubyonrailsin 0 comments
On 2 April 2010 21:00, WSzP <ctdd@ctdd.ro> wrote:
> You got me wrong. I can't put the create method in the student
> controller.
> The question if, how could I use the create method from the
> BeiratkozasController class, while the model is NOT Beiratkozas, but
> Student.

Have a look at the docs for form_for, you will see it has a url
parameter which will allow you to specify the controller and action
that you wish to be performed on the submit.

Colin

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

Read More…

[spree-user] Re: Order processing flow with default setup?

by rubyonrailsin 0 comments
Thanks lesfreeman. I used OmniGraffle.

On Apr 2, 2:51 am, lesfreeman <lesliefreem...@gmail.com> wrote:
> Danisev,
> Sure enough. :)
>
> I thought I had tried a new order, but apparently not. Worked just
> fine.
>
> Thanks!
>
> Also, Daniel Amselem, that's a great diagram. What tool did you use to
> make it?
>
> On Apr 1, 2:17 pm, danisev <anie...@gmail.com> wrote:
>
>
>
> > lesfreeman,
>
> > I had the same problem and I posted[1] but I didn't find response.
>
> > I think that this behaviour only occurs with the loaded sample data
> > with rake db:bootstrap.. Try to create a new order and you'll see that
> > all the flow is like Brian says.
>
> > [1]http://groups.google.com/group/spree-user/browse_thread/thread/1d2a68...

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To post to this group, send email to spree-user@googlegroups.com.
To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Read More…

Re: [Rails] Re: Weird date/time incompatibility

by rubyonrailsin 0 comments
On 2 April 2010 20:42, Dudebot <craignied@gmail.com> wrote:
>
>
> On Apr 2, 6:30 am, Colin Law <clan...@googlemail.com> wrote:
>
>> You say the html is correct in the index view so it cannot be an issue
>> passing the dates to the index view, or you would see the wrong dates
>> there.
>
> Thanks for helping with this.  What I see in the development html is ?
> date=2010-03-31+18%3A19%3A00+UTC
> and what I see in the production html is ?date=Thu+Apr
> +01+23%3A02%3A00+-0500+2010
> and I'm wondering if somehow it's choking on the date format on the
> production server...

Am I right in assuming that is what is contained in the <a href link
in the html? If so then the first thing is that they are in different
timezones. Can you confirm that you are definitely seeing the above
dates with the same version of the code. You said you had been
experimenting with setting the timezone in rails, are you sure you
have updated the production server and restarted it with the same code
as on your development system.

Do you want to see a local time there or UTC?

What have you currently got the timezone set to in environment.rb?

The second thing is that they are formatted differently. How are you
formatting it in your erb code? If you have not got explicit format
it might be worth doing so.

Colin

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

Read More…

[Rails] Re: Two controllers with create using the same model

by rubyonrailsin 0 comments
You got me wrong. I can't put the create method in the student
controller.
The question if, how could I use the create method from the
BeiratkozasController class, while the model is NOT Beiratkozas, but
Student.
WSZP

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

Read More…

[Rails] Re: Two controllers with create using the same model

by rubyonrailsin 0 comments
You got me wrong. I can't put the create method in the student
controller.
The question if, how could I use the create method from the
BeiratkozasController class, while the model is NOT Beiratkozas, but
Student.
WSZP

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

Read More…

[Rails] Re: Accessing models in "mounted" Rails 3 app

by rubyonrailsin 0 comments
I think I just realized why this is happening. The container app is
just a sample for testing out the mounted app, and I named it "Shop".
I imagine there's some kind of conflict going on between the Shop
defined in application.rb and the Shop defined in the model.

Gonna go test this now, but I think that pretty much solves this
mystery.

On Apr 2, 9:33 am, Angelo Ashmore <studiopd....@gmail.com> wrote:
> Okay, it looks like Rails is pulling an April Fools on me. It like 18
> of the 19 models are accessible. I tried to list all the models using:
>
> ActiveRecord::Base.send(:subclasses).each { |model| puts model.name }
>
> and it only returned three of the models. Accessing all the models
> directly (typing "Image" in the console, for example) accesses them
> correctly.
>
> My Shop model, however, is still causing problems. Shop is definitely
> accessible in the mounted app, but acts as if it does not exist in the
> container app.
>
> Angelo
>
> On Apr 1, 3:11 pm, Angelo Ashmore <studiopd....@gmail.com> wrote:
>
>
>
> > This is the first time I'm working with Engine's in Rails, let alone
> > in Rails 3. I basically followed these steps to set up the mountable
> > app:http://blog.dynamic50.com/index.php/2010/02/rails-3-0-mount-multiple-...
>
> > Now that the mountable app is built, I'm moving on to create the
> > container app. In doing so, however, I am having trouble accessing the
> > models in the mounted app.
>
> > Shop is a model I have the the mounted app, and when I try to access
> > it in the container app, this is returned:
>
> > >> Shop.first
>
> > => NoMethodError: undefined method `first' for Shop:Module
>
> > Strangely enough, however, 3 of the mounted app's 19 models are
> > accessible in the container app. Shop.class.name returns "Module"
> > while Employee.class.name returns "Class" (Employee is a working model
> > in the container app).
>
> > I'm quite lost on this. Any help is greatly appreciated!
>
> > Thanks,
> > Angelo

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

Read More…

[Rails] Re: Weird date/time incompatibility

by rubyonrailsin 0 comments
On Apr 2, 6:30 am, Colin Law <clan...@googlemail.com> wrote:

> You say the html is correct in the index view so it cannot be an issue
> passing the dates to the index view, or you would see the wrong dates
> there.

Thanks for helping with this. What I see in the development html is ?
date=2010-03-31+18%3A19%3A00+UTC
and what I see in the production html is ?date=Thu+Apr
+01+23%3A02%3A00+-0500+2010
and I'm wondering if somehow it's choking on the date format on the
production server...

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

Read More…

Re: [Radiant-Dev] [ANN] PageFactory extension

by rubyonrailsin 0 comments
On Fri, Apr 2, 2010 at 3:01 PM, Josh French <josh@digitalpulp.com> wrote:
> If the above method is available to the controller/view, then it already has
> access to the @page instance and current user, plus anything else I can find
> in the current request.
>
> On the other hand, Page#factories(current_user=nil) implies there's only one
> dimension you can filter on. It makes it harder for extensions which might
> want to filter by something we haven't thought of yet.

Good point.

>
>> On a side note, another thing I realized is that there should be some
>> description for the available templates.
>
> This would be nice. Do we have an existing UI pattern for a modal containing
> a table instead of a select element?

I don't believe we do.

--
Jim Gay
http://www.saturnflyer.com

--
Radiant CMS Dev Mailing List
Post: radiantcms-dev@googlegroups.com
Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
Group Site: http://groups.google.com/group/radiantcms-dev/

Read More…

[Rails] Re: Accessing models in "mounted" Rails 3 app

by rubyonrailsin 0 comments
Okay, it looks like Rails is pulling an April Fools on me. It like 18
of the 19 models are accessible. I tried to list all the models using:

ActiveRecord::Base.send(:subclasses).each { |model| puts model.name }

and it only returned three of the models. Accessing all the models
directly (typing "Image" in the console, for example) accesses them
correctly.

My Shop model, however, is still causing problems. Shop is definitely
accessible in the mounted app, but acts as if it does not exist in the
container app.

Angelo

On Apr 1, 3:11 pm, Angelo Ashmore <studiopd....@gmail.com> wrote:
> This is the first time I'm working with Engine's in Rails, let alone
> in Rails 3. I basically followed these steps to set up the mountable
> app:http://blog.dynamic50.com/index.php/2010/02/rails-3-0-mount-multiple-...
>
> Now that the mountable app is built, I'm moving on to create the
> container app. In doing so, however, I am having trouble accessing the
> models in the mounted app.
>
> Shop is a model I have the the mounted app, and when I try to access
> it in the container app, this is returned:
>
> >> Shop.first
>
> => NoMethodError: undefined method `first' for Shop:Module
>
> Strangely enough, however, 3 of the mounted app's 19 models are
> accessible in the container app. Shop.class.name returns "Module"
> while Employee.class.name returns "Class" (Employee is a working model
> in the container app).
>
> I'm quite lost on this. Any help is greatly appreciated!
>
> Thanks,
> Angelo

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

Read More…

Re: [Radiant-Dev] [ANN] PageFactory extension

by rubyonrailsin 0 comments
> But more to the point, the Radiant UI really shouldn't allow you to
> add 2 ArchiveMonthlyIndexPage pages but it currently does. If creating
> new pages was done with PageFactory, then you could have the
> ArchivePage#factories method check to see if it had a child of
> ArchiveMonthlyIndexPage already and remove that from the list of
> available templates.

OK, now I see the use case. In this instance, it really is the Page
class that cares about what factories are available. The general
problem though is that you've got an extension which needs to modify
factory selection, and will be delegating that responsibility to a
specific model.

Let's use your example and add extension that scopes factories by
role. That doesn't involve the page at all, but both extensions are
just filtering the list of factories by arbitrary criteria. The
general solution would just be a chainable filter:

def factories
[PageFactory, *PageFactory.descendants]
end

def factories_with_singleton
factories_without_singleton.reject { |f|
@page.page_factory.singleton_exists?(f) }
end
alias_method_chain :factories, :singleton

def factories_with_roles
factories_without_roles.select { |f| (f.roles &
current_user.roles).any? }
end
alias_method_chain :factories, :roles

> If it's only in ActionView where this can be done then the ability to
> do things like this is more restricted

If the above method is available to the controller/view, then it
already has access to the @page instance and current user, plus
anything else I can find in the current request.

On the other hand, Page#factories(current_user=nil) implies there's
only one dimension you can filter on. It makes it harder for
extensions which might want to filter by something we haven't thought
of yet.

> On a side note, another thing I realized is that there should be some
> description for the available templates.

This would be nice. Do we have an existing UI pattern for a modal
containing a table instead of a select element?

j


On Apr 2, 2010, at 1:49 PM, Jim Gay wrote:

> On Fri, Apr 2, 2010 at 11:04 AM, Josh French <josh@digitalpulp.com>
> wrote:
>>> Then different extensions could do some alias_method trickery to
>>> play nice
>>> with each other.
>>
>> Postscript: I think this is the point we're circling. I had not
>> really
>> thought through how other extensions might use the more forward-
>> facing
>> features. In my mind, Page Factory is mostly plumbing. You might
>> share some
>> factories between projects, but the rules governing who can do what
>> with
>> them, and where, are usually pretty tailored to the application. So
>> if
>> that's the part I expect to rewrite every time, I want it isolated.
>>
>> But it sounds like you're anticipating a different use case, in which
>> multiple extensions are providing and modifying access to
>> factories. Can you
>> describe a scenario in which you'd expect to use Page Factory like
>> that?
>> (It's great that people are thinking of ways to use this to solve
>> problems
>> that look nothing like mine!)
>>
>
> Yeah. I think we're talking about the same thing too. I just think it
> might be easier to use a method on the Page model and its descendants.
>
> This is how I imagined it:
>
> The Page model would have
>
> def factories
> :all # or something
> end
>
> Then an extension that I create to manage newsletters, for example,
> could have a NewsletterIndexPage and NewsletterIssuePage with a bunch
> of custom radius tags.
>
> In the NewsletterIndexPage model, I would do
>
> def factories
> ['NewsletterIssueFactory'] # or something like this
> end
>
> Then when I clicked on a NewsletterIndexPage to add a child, it would
> add a child of the given type (if there is only one type) or if there
> are more than one option then it would give me the options to select
> from the list of available factories.
>
> Or if you used a current_user:
>
> def factories(current_user=nil)
> if current_user && current_user.admin?
> super # or some other defined list
> else
> ['NewsletterIssueFactory'] # or maybe [:newsletter_issue] if you
> swing that way
> end
> end
>
> So I would still make the default setup in PageFactory (the extension)
> return all and allow the overrides to be done by any new Page classes.
> Or some client-specific extension could override Page#factories, or
> alias it to do their own url checking scheme or do other client
> pleasing things.
>
> If it's only in ActionView where this can be done then the ability to
> do things like this is more restricted (or am I wrong about that?).
>
> But more to the point, the Radiant UI really shouldn't allow you to
> add 2 ArchiveMonthlyIndexPage pages but it currently does. If creating
> new pages was done with PageFactory, then you could have the
> ArchivePage#factories method check to see if it had a child of
> ArchiveMonthlyIndexPage already and remove that from the list of
> available templates.
>
> But I think this really polishes up the use of Radius. It's one thing
> to have a tag reference in the UI, but it's entirely better to provide
> a safe way to create the radius content without worrying if you're
> doing it right. I see PageFactory as a way that any extension which
> adds a new subclass of Page ought to provide a sample setup.
>
> On a side note, another thing I realized is that there should be some
> description for the available templates. A select list is simple
> enough, but if there were a slightly different list which gave a
> description from the factory class, it would reduce the training
> needed to understand when to use what factory. So your instead of your
> list having "Revenge" it would have "Revenge: a template to make a
> list of all the people who wouldn't let you borrow their pencil
> sharpeners in grade school"
>
> --
> Jim Gay
> http://www.saturnflyer.com
>
> --
> Radiant CMS Dev Mailing List
> Post: radiantcms-dev@googlegroups.com
> Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
> Group Site: http://groups.google.com/group/radiantcms-dev/
>
> To unsubscribe, reply using "remove me" as the subject.

--
Radiant CMS Dev Mailing List
Post: radiantcms-dev@googlegroups.com
Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
Group Site: http://groups.google.com/group/radiantcms-dev/

Read More…

Subscribe feeds via e-mail

Blog Archive