[Rails] sessions

2010-05-02 Thread Rajkumar Surabhi
hi all,

in my application i have to maintain the user information in session and
updates the table flag when the user logins and while loggingout i
change the flag to zero.

i want to delete the stale sessions and while doing this i want to
perform operation on tables how to do this.

Please let me know


Regards,
Rajkumar.surabhi
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Select inside a hidden div

2010-05-02 Thread Bob Smith
_household.html.erb
<%= observe_field   :household_zip,
:url => {:controller => 'households', :action => 
'watch_church'},
:update => :church,
:with => '@churches',
:frequency=> 0.5  %>




household_controller.html.erb
def watch_church
  if (params['zip'] != "01540") && (params['zip'] != "01537") then
render :partial => "church_select"
  else
render(:nothing=>true)
  end
end

_church_select.hmtl.erb
Member of Local Church:   <% select("church", "church_id",
Church.all.collect{|p| [p.name, p.id]}) %> 


On Apr 21, 3:30 am, Colin Law  wrote:
> On 21 April 2010 05:38, Bob Smith  wrote:
>
> > Is there any way to use select inside a hidden div block with a model
> > object for the select items ? I have the block showing and hiding OK
> > with observe_field, but the variable I'm using to see whether to show/
> > hide seems to be the only one allowed by the :with option to
> > observe_field, so I can't see a way to get the model variable to the
> > select box. I tried leaving it as it was before the observe_field and
> > partial, but it doesn't see the variable anymore to populate the
> > choices..
>
> I think you will need to show us some view code.  The minimum that
> shows the problem please.
>
> 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-t...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Having trouble with Validatable

2010-05-02 Thread Bob Smith
I need to use the level option for my app, so I did 'gem install
validatable'

Next I got an error when it tried to run, so after some searching,
'require 'validatable' in environment.rb

Now it says 'Unknown key(s): level' when a view tries to render a
partial from that model..

class Person < ActiveRecord::Base
  include Validatable
belongs_to :household

  validates_numericality_of :month_int, :level => 1
  validates_numericality_of :day_int, :level => 1
  validates_numericality_of :year_int, :level => 1
  validates_presence_of :sex, :m, :d, :y
  validates_length_of :sex, :is => 1
  validates_date :birthday, :after => Date.new(1900, 1, 1), :before =>
Proc.new { 1.day.from_now.to_date }, :before_message => 'Ensure it is
before %s', :after_message => 'Ensure it is after %s', :level => 2
  before_validation do
  #  debugger
self.month_int = self.m.to_i
self.day_int = self.d.to_i
self.year_int = self.y.to_i
  end
  after_validation do
debugger
self.birthday = Date.new(self.year_int, self.month_int,
self.day_int)
  end
end

Please help..

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Sluggish Webrick?

2010-05-02 Thread Karthikeyan
Hi, I noticed recently that style sheets and javascrips in my rails
app under development does not loads properly, when I tried to access
it this is what  I got:



  Internal Server Error
  
Internal Server Error
private method `gsub!' called for #



 WEBrick/1.3.1 (Ruby/1.8.7/2010-01-10) at
 localhost:3000

  


Any  body knows whats wrong and how to fix it?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Scriptaculous, snap draggable to droppable or revert

2010-05-02 Thread Anthony Mompoint


Hello community,

I am a fairly new RoR programmer and I need some help with Scriptaculous
Drag and Drop:

So I have

<%= draggable_element(@div_id, :revert => "failure", :snap => 5) -%>

and a droppable:

<%= drop_receiving_element(@team_div_id,  :with => "'player=' +
(element.id)+ '&position=' + #{draft_position}" ,:complete =>
visual_effect(:highlight), :update=>"status" , :url => { :action =>
"receive_drop"}, :hoverclass => 'hover' ) %>
<% end %>

I would like to allow the draggable to "snap" to a droppable position if
close or revert back to its original position if it isnt near a
droppable.

I have searched over the net but I have been unsuccessful with this
issue. I understand there's the Snap option but I want it to snap INTO a
droppable when close or go back to its original position.

I have found some example code such as:


//


But how do I translate that using drop_receiving_element?

Can anyone help me with this, or point me in the right position?
Essentially its just "Snap to a grid" but I have been unable to find a
simple example. I appreciate the help!
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: database.yml: encoding: utf8 does not work

2010-05-02 Thread Edmond Chui
Joshua Muheim wrote:
> Hi all
> 
> According to the Agile 2nd Ed book I added the line encoding: utf8 to my
> database.yml connections.
> 
> But now when running rake I get plenty of errors:
> 
> Character set 'utf-8' is not a compiled character set and is not
> specified in the '/usr/local/mysql/share/mysql/charsets/Index' file
> 
> What's wrong here?
> I checked this Index file, but it seems to be empty...
> 
> Thanks a lot
> Josh

You have to make sure your database is created to utf8 as the default 
character set.
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: rails ROUTING map.root

2010-05-02 Thread Ritchie
Hi David,

Your conditional routing won't work because routes.rb is evaluated on
startup not per request.

I don't understand the rest of the question. You can't redirect
multiple times per action but you can have multiple possible redirects
in an action as long as only one is executed - does that help?

/Ritchie

On May 2, 10:38 am, David Zhu  wrote:
> Is it possible to put an if/else statemnt, and change the map.root
> under each condition? for ex--
>
> if current_user
> map.root :controller => 'current_user'
>
> else
>
> map.root :controller => 'home'
>
> end
>
> cuase apparenlty that doesn't work, so is there an alternative way?
> basically if the user is logged in, i dont want the homepage to be the
> homepage anymore, but instead the user page.
>
> NOTE i can't do a redirect_to in my home controller, because i
> have multiple cases (current_user, current_admin, etc) and i can't
> have multiple redirects in an action.
>
> so is there a way to change the homepage according to who's logged in?
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Mephisto status?

2010-05-02 Thread Vitaly Kushner
Weird, it is gone indeed.
It was there last time I checked which was not too long ago.
CAn be a temporary issue.

On May 3, 12:48 am, avramd  wrote:
> Can anyone tell me the status of Mephisto w/rt current rails? Is it
> still being developed?
>
> From all of my googling, the site for it seems like it was
> mephistoblog.com, and it doesn't appear to exist any more.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Mephisto status?

2010-05-02 Thread avramd
Can anyone tell me the status of Mephisto w/rt current rails? Is it
still being developed?

>From all of my googling, the site for it seems like it was
mephistoblog.com, and it doesn't appear to exist any more.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Rail's App structure in Gem?

2010-05-02 Thread elliottg
I have been looking at the source of some Gems... Within some, I see
an App structure that emulates part of Rail's App structure, i.e,
Controller, Helpers, Models, Views etc

How do Gem centric paths work when a Rails style App dir is part of a
Gem's design? Do paths to contollers and views created in the Gem
defer to it's App dir instead of the rails_root/app?

Any thoughts or links to useful resources are appreciated.

Thanks, Elliott

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] struggling with accepts_nested_attributes_for

2010-05-02 Thread Kevin Tambascio
Hi,

I've been struggling with getting accepts_nested_attributes_for to work
perfectly with a nested model form.  This is a project that was started
before Rails 2.0, and I'm trying to use new techniques in the new
functionality.  I'm presently using Rails 2.3.4.  I'm down to one last
issue, and I'm not finding an answer so far.

The system I'm building deals with Items that have ResponseItem's as
children (think questions with multiple choices). Creating a new item
works fine.  By default, the item has 12 potential responses.  A form is
rendered that allows the user to enter up to 12 responses.  The saving
of the new item works fine.

The issue is with editing.  Say the item was created with 4 responses.
When the edit form is rendered, 4 of the responses are shown, and the
other 8 are blank (only the first 4 are representing objects in the
databases, the blank ones have no database records).  When the form is
submitted, I'm receiving an HTTP 500 error, with this output in the log:

Completed in 176ms (View: 95, DB: 22) | 200 OK
[http://localhost/items/edit/648?assessment_id=1]
/!\ FAILSAFE /!\  Sun May 02 21:04:01 UTC 2010
  Status: 500 Internal Server Error
  expected Array (got Hash) for param `response_items_attributes'
/opt/jruby-1.4.0/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/utils.rb:85:in
`normalize_params'
/opt/jruby-1.4.0/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/utils.rb:94:in
`normalize_params'
/opt/jruby-1.4.0/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/utils.rb:62:in
`parse_nested_query'
/opt/jruby-1.4.0/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/utils.rb:60:in
`each'
/opt/jruby-1.4.0/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/utils.rb:60:in
`parse_nested_query'

/opt/jruby-1.4.0/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/request.rb:140:in
`POST'


The call stack does not even show my code, it's all framework so far.

The models look like this:

class Item < ActiveRecord::base
  ...
  attr_accessor :response_item_ids
  has_many :response_items
  accepts_nested_attributes_for :response_items, :allow_destroy => true,
:reject_if => proc { |attributes| attributes['Response'].blank? }
  ...
end

class ResponseItem < ActiveRecord::base
  ...
  belongs_to :item
  ...
end

The only real clue so far, is the names of the fields on the edit form
are different whether it's a pre-filled response, or a blank one.

This is for a response that has an item in the database:


  

This is for a blank response item, with no object in the database:


  

My hunch is that mixing a form with some items that have an ID, and some
that are blank for an ID, is potentially causing trouble in the
normalize_params function?

One possible solution could be that for blank responses, I create a
temporary database item, so that they have an ID field filled out.  When
I try to edit an item with all 12 responses, it does work because
there's an ID field for each response.

Clear as mud?  :)  Tough to explain this in a forum.  If anyone has any
thoughts, I'd appreciate it.

Thanks,
Kevin
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: dev tool

2010-05-02 Thread nirosh
Aptana RadRail,Netbeans i'm using these 2 for my dev. pretty cool for
me try it.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: dev tool

2010-05-02 Thread Vitaly Kushner
I'd suggest TextMate if you had a Mac, but then I guess you wouldn't
be asking :)
So I suppose you are on Windows or Linux. In which case I recommend
vim :).

This is what I'm using and I do have a Mac (actually 3 of them :)

I used TextMate for a couple of years but eventually got drown back to
vim.
I just can't give up the power it has.

My .vimrc setup with a lot of rails related goodies can be found at
http://github.com/astrails/dotvim

There is a README with most useful

On May 2, 11:39 pm, Mlle  wrote:
> Can anyone suggest a development tool for RoR?  How is the plugin for
> Eclipse?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] dev tool

2010-05-02 Thread Larry Meadors
I like RubyMine - it's not free, but worth it, IMO.

Larry


On Sun, May 2, 2010 at 2:39 PM, Mlle  wrote:
> Can anyone suggest a development tool for RoR?  How is the plugin for
> Eclipse?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] dev tool

2010-05-02 Thread Mlle
Can anyone suggest a development tool for RoR?  How is the plugin for
Eclipse?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Finding the next item, in a group of items.

2010-05-02 Thread Joe
Ok, So it seems that this whole tutorial ordering thing seems to be
the best way to go (thanks to philip anyway for giving me the code to
do it with ids if I wanted to);
The problem is I'm really a complete noob in RoR. I know how to create
migrations, however creating a "position" variable i which they were
independent to the category the tutorials were in; I have absolutely
no idea how to do that. And you talk about writing methods, I also do
not know where these methods would be created (inside a controller
perhaps?).

Any help with this task would be kindly appriciated,

Thanks In Advance,

Joe

On May 2, 7:18 pm, Philip Hallstrom  wrote:
> >> The tutorials are then displayed in order of there id (auto-
> >> incrementing) in their categories show method.
> >> The thing is, I want to create a link that goes from one tutorial
> >> (with an id of 10 for example) to the next tutorial in that category
> >> (which might not have an id of 11, as I create different tutorials at
> >> different times, therefore creating different ids for two tutorials
> >> seemingly next to eachother in order).
>
> >> Obviously I know I will need something like this:
> >> <%= link_to 'Next lesson',   %>
>
> >> but I just don't know how I can manage it..
>
> >> By the way, every tutorial has a: category_id  to determain which
> >> category they are in (this is an integer).
>
> > If I were you, i'd create a position column on tutorials, which
> > determines the ordering of tutorials for a category (ordering by id
> > might seem the simplest but stops you from ever reordering tutorials.
> > Given a tutorial, the next one is the first one in the same category
> > whose position is greater than the current ones (you could write a
> > next_tutorial method on tutorial). There's a plugin called
> > acts_as_list that you might find helpful maintaining the position
> > column. If you're hell bent on ordering by id then it's as if id is
> > your position column
>
> > Fred
>
> I agree with Fred as it allows you to easily re-order the tutorials if  
> you want to, but if you don't... then...
>
> next_tutorial = Tutorial.find(:conditions => ["id > ? AND category_id  
> = ?", current_tutorial_id, current_category_id], :order =>  
> 'id', :limit => 1)
>
> prev_tutorial = Tutorial.find(:conditions => ["id < ? AND category_id  
> = ?", current_tutorial_id, current_category_id], :order => 'id  
> DESC', :limit => 1)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: DB structure of a translation Web service

2010-05-02 Thread Walter McGinnis
On Mon, May 3, 2010 at 3:06 AM, oren  wrote:
> Thanks Walter.
> Kete looks like an awesome project.

Thanks. It's been good to work on and useful.

>
> It looks like the simplest solution for me would be to add language_id
> field to my content table and maybe later on
> I'll refactor it to other solution.

I usually store locale in the table for the content without splitting
out to a languages (or locales) table and storing a locale_id.  Rails
only stores i18n.locale as a symbol.  I haven't had a need for tighter
constraints on the data for locale than that.

> mongo db sounds awesome, but I am
> not sure where to start - the github page doesn't explain about
> installing/using it.

Yep, that's in the works.  In the meantime, check out
http://github.com/kete/mongo_translatable/tree/master/test/full_2_3_5_app_with_tests
which is a full (but simple) Rail 2.3.5 app for testing purposes.  You
can dig around there, including the tests, to see the basics about how
to mongo_translatable works.  I'll get to the README before too long.

Cheers,
Walter

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Finding the next item, in a group of items.

2010-05-02 Thread Philip Hallstrom

The tutorials are then displayed in order of there id (auto-
incrementing) in their categories show method.
The thing is, I want to create a link that goes from one tutorial
(with an id of 10 for example) to the next tutorial in that category
(which might not have an id of 11, as I create different tutorials at
different times, therefore creating different ids for two tutorials
seemingly next to eachother in order).

Obviously I know I will need something like this:
<%= link_to 'Next lesson',   %>

but I just don't know how I can manage it..

By the way, every tutorial has a: category_id  to determain which
category they are in (this is an integer).



If I were you, i'd create a position column on tutorials, which
determines the ordering of tutorials for a category (ordering by id
might seem the simplest but stops you from ever reordering tutorials.
Given a tutorial, the next one is the first one in the same category
whose position is greater than the current ones (you could write a
next_tutorial method on tutorial). There's a plugin called
acts_as_list that you might find helpful maintaining the position
column. If you're hell bent on ordering by id then it's as if id is
your position column

Fred


I agree with Fred as it allows you to easily re-order the tutorials if  
you want to, but if you don't... then...


next_tutorial = Tutorial.find(:conditions => ["id > ? AND category_id  
= ?", current_tutorial_id, current_category_id], :order =>  
'id', :limit => 1)


prev_tutorial = Tutorial.find(:conditions => ["id < ? AND category_id  
= ?", current_tutorial_id, current_category_id], :order => 'id  
DESC', :limit => 1)


--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Finding the next item, in a group of items.

2010-05-02 Thread Frederick Cheung


On May 2, 1:29 pm, Joe  wrote:
>
> The tutorials are then displayed in order of there id (auto-
> incrementing) in their categories show method.
> The thing is, I want to create a link that goes from one tutorial
> (with an id of 10 for example) to the next tutorial in that category
> (which might not have an id of 11, as I create different tutorials at
> different times, therefore creating different ids for two tutorials
> seemingly next to eachother in order).
>
> Obviously I know I will need something like this:
> <%= link_to 'Next lesson',   %>
>
> but I just don't know how I can manage it..
>
> By the way, every tutorial has a: category_id  to determain which
> category they are in (this is an integer).
>

If I were you, i'd create a position column on tutorials, which
determines the ordering of tutorials for a category (ordering by id
might seem the simplest but stops you from ever reordering tutorials.
Given a tutorial, the next one is the first one in the same category
whose position is greater than the current ones (you could write a
next_tutorial method on tutorial). There's a plugin called
acts_as_list that you might find helpful maintaining the position
column. If you're hell bent on ordering by id then it's as if id is
your position column

Fred

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: DB structure of a translation Web service

2010-05-02 Thread oren
Thanks Walter.
Kete looks like an awesome project.

It looks like the simplest solution for me would be to add language_id
field to my content table and maybe later on
I'll refactor it to other solution. mongo db sounds awesome, but I am
not sure where to start - the github page doesn't explain about
installing/using it.


On May 2, 4:50 am, Walter McGinnis  wrote:
> HI oren,
>
> There was recent similar discussion about design for content
> translations and the answer I gave there may be useful to you:
>
> http://osdir.com/ml/RubyonRailsTalk/2010-04/msg02235.html
>
> I'm currently adding content translation to the Kete open source Rails
> app (http://github.com/kete/keteandhttp://kete.net.nz).  You may
> find some example code there useful.
>
> A lot of people, including myself 
> withhttp://github.com/kete/mongo_translatable, are starting to use a NoSQL
> backend for translation.  The latest I18n gem just added Tokyo Cabinet
> support, too.
>
> Hope this helps,
> Walter
>
>
>
> On Sun, May 2, 2010 at 4:40 PM, oren  wrote:
> > I am building a Web service that will provide content for different
> > client via Rest API.
>
> > currently I have:  content has_many :keys (since many keys can
> > reference the same content)
> > content table has only one field - text
> > keys table has name and content_id
>
> > example for key: help_about
> > example for content: "This website is for blablabla.."
>
> > I want to add support for translations.
> > is it reasonable to store the content in separate table for each
> > language?
> > for example - content_english, content_spanish, etc.
> > If it is, how will rails handle it? currently Content.find 1 will
> > return the text of contents table.
> > and I will need to tell rails to grab it from content_english or
> > content_spanish.
>
> > btw, I looked at a gettext example and it uses only one table with
> > locale field to determine what language to show.  but I am not sure
> > it's a good solution for massive chunk of content and many languages.
>
> > Thanks!
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Ruby on Rails: Talk" group.
> > To post to this group, send email to rubyonrails-t...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > rubyonrails-talk+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://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-t...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: DB structure of a translation Web service

2010-05-02 Thread oren
Thanks Walter.
Kete looks like an awesome project.

It looks like the simplest solution for me would be to add language_id
field to my content table and maybe later on
I'll refactor it to other solution. mongo db sounds awesome, but I am
not sure where to start - the github page doesn't explain about
installing/using it.


On May 2, 4:50 am, Walter McGinnis  wrote:
> HI oren,
>
> There was recent similar discussion about design for content
> translations and the answer I gave there may be useful to you:
>
> http://osdir.com/ml/RubyonRailsTalk/2010-04/msg02235.html
>
> I'm currently adding content translation to the Kete open source Rails
> app (http://github.com/kete/keteandhttp://kete.net.nz).  You may
> find some example code there useful.
>
> A lot of people, including myself 
> withhttp://github.com/kete/mongo_translatable, are starting to use a NoSQL
> backend for translation.  The latest I18n gem just added Tokyo Cabinet
> support, too.
>
> Hope this helps,
> Walter
>
>
>
> On Sun, May 2, 2010 at 4:40 PM, oren  wrote:
> > I am building a Web service that will provide content for different
> > client via Rest API.
>
> > currently I have:  content has_many :keys (since many keys can
> > reference the same content)
> > content table has only one field - text
> > keys table has name and content_id
>
> > example for key: help_about
> > example for content: "This website is for blablabla.."
>
> > I want to add support for translations.
> > is it reasonable to store the content in separate table for each
> > language?
> > for example - content_english, content_spanish, etc.
> > If it is, how will rails handle it? currently Content.find 1 will
> > return the text of contents table.
> > and I will need to tell rails to grab it from content_english or
> > content_spanish.
>
> > btw, I looked at a gettext example and it uses only one table with
> > locale field to determine what language to show.  but I am not sure
> > it's a good solution for massive chunk of content and many languages.
>
> > Thanks!
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Ruby on Rails: Talk" group.
> > To post to this group, send email to rubyonrails-t...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > rubyonrails-talk+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://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-t...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Rails Authorization plugins

2010-05-02 Thread Leonardo Mateo
On Sun, May 2, 2010 at 10:12 AM, jmamma  wrote:
> We are evaluating authorization plugins for rails and I wanted to
> address the group for some feedback.
>
> The two we are looking at are: cancan by Ryan Bates  and
> declarative_authorization.
>
> If anyone has used either of these and can give me some feedback on
> how they have worked out for you that would be great!  We would be
> using one of these in conjunction with the restul_auth plugin btw.
>
> One monkey wrench our project throws in to the mix is that we have a
> multiple database
> per customer model so I'm aware we'll need to make some changes to the
> plugin in order
> to make it fit.  So if you have customized either of the plugins I
> would like how easy / difficult that was.
>
> --
I'm using declarative_authorization and I like it a lot.
Also, +1 to authlogic instead of restful_authentication.


-- 
Leonardo Mateo.
There's no place like ~

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Rails Authorization plugins

2010-05-02 Thread Michael Schuerig
On Sunday 02 May 2010, jmamma wrote:
> The two we are looking at are: cancan by Ryan Bates  and
> declarative_authorization.

I had the same candidates recently and decided to use CanCan. I think 
that they are very similar in spirit, declarative_authorization is far 
more elaborate and consequently more complex. CanCan is much simpler. As 
I don't need more than CanCan provides, I went with it.

If you need model-based security over and above resource/controller-
based checks, than declarative_authorization is the way to go.

> We would be
> using one of these in conjunction with the restul_auth plugin btw.

Have you had a look at authlogic for comparison?

Michael

-- 
Michael Schuerig
mailto:mich...@schuerig.de
http://www.schuerig.de/michael/

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Rails Authorization plugins

2010-05-02 Thread jmamma
We are evaluating authorization plugins for rails and I wanted to
address the group for some feedback.

The two we are looking at are: cancan by Ryan Bates  and
declarative_authorization.

If anyone has used either of these and can give me some feedback on
how they have worked out for you that would be great!  We would be
using one of these in conjunction with the restul_auth plugin btw.

One monkey wrench our project throws in to the mix is that we have a
multiple database
per customer model so I'm aware we'll need to make some changes to the
plugin in order
to make it fit.  So if you have customized either of the plugins I
would like how easy / difficult that was.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Finding the next item, in a group of items.

2010-05-02 Thread Joe
Hi,

Basically I currently have this system where there are categories, and
tutorials; obviously categories have many tutorials, and every
tutorial must belong_to a category.

The tutorials are then displayed in order of there id (auto-
incrementing) in their categories show method.
The thing is, I want to create a link that goes from one tutorial
(with an id of 10 for example) to the next tutorial in that category
(which might not have an id of 11, as I create different tutorials at
different times, therefore creating different ids for two tutorials
seemingly next to eachother in order).

Obviously I know I will need something like this:
<%= link_to 'Next lesson',   %>

but I just don't know how I can manage it..

By the way, every tutorial has a: category_id  to determain which
category they are in (this is an integer).


Please Help,

Thanks In Advance,

Joe

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Drop down menu and ajax calls

2010-05-02 Thread Bill Walton
Hi Ahmed,

On Sun, May 2, 2010 at 1:32 AM, Ahmed Abdelsalam wrote:

> Hi,
>
> I have a drop down menu that contains a set of menu items. Each menu
> item is planned to make ajax call to change the content of the page when
> it's clicked. I used link_to_remote successfully to make the ajax call
> and update the specific div
>
> However, After clicking the menu item, the menu doesn't close, and it
> remains open. The contents already changed in the background, but the
> menu is still open, which hides a part of the page.
>

I'm not sure I understand what you mean 'used link_to_remote...'.  I'm
imagining that you've coded the menu items themselves with the link.  If so,
that's an interesting approach, but one that I've never tried.  I'm guessing
it might be why your menu is misbehaving.  I use observe_field on the
select, passing the selected value to render the new content.  You might try
that to see if yields better results.

Best regards,
Bill

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Passenger Processes Users

2010-05-02 Thread Felix Schäfer
Am 01.05.2010 um 20:51 schrieb Maz:

> I was wondering if it is possible to have passenger spawn each of its
> rails processes on a different user account.

Yes, a different user for each app, see the Passenger docs 
http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerUserSwitching

Felix

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Problems with _path and _url helpers using namespaced controller

2010-05-02 Thread re5et
I am using a namespaced controller as described here
http://guides.rubyonrails.org/routing.html#controller-namespaces-and-routing

When using:

map.with_options(:namespace => "admin")  do |admin|
admin.resources :photos, :videos end

and then attempting to use the path/url helper new_photo_path it links
to photos/new instead of admin/photos/new as expected.

How can I acheive the expected behavior?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Passenger Processes Users

2010-05-02 Thread Maz
Hi all,

I was wondering if it is possible to have passenger spawn each of its
rails processes on a different user account.

Thanks,
Maz

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] validation message in other module

2010-05-02 Thread Rahul Mehta
i am having one comment module and putted the two validation and i
have putted or copy the code of the add form of this module to my
public module

and when user add comment from the public module the customer flag is
1
and validations are not working how i can make it work

my comment module create function is this and m using this function
for both the module..

def create
@comment = Comment.new(params[:comment])
respond_to do |format|
  if @comment.save
flash[:notice] = 'comment was successfully created.'
if(params[:customer]=="1")

  format.html { redirect_to root_url+params[:menu]
+"/"+params[:menu1] }
else
  #format.html{render :text=>params[:customer]}
  format.html { redirect_to(@comment) }
end
format.xml  { render :xml => @comment, :status
=> :created, :location => @comment }
  else
 if(params[:customer]=="1")
  format.html { redirect_to root_url+params[:menu]
+"/"+params[:menu1] }
else
  format.html { render :action => "new" }
end

format.xml  { render :xml => @comment.errors, :status
=> :unprocessable_entity }
  end
end

  end

please help ASAP.

thanks

rahul

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.