[Rails] ruby array inside hash is nil.

2010-03-18 Thread Me
I assign an array to a hash value.  When I inspect it shows the array
but when I try to access the array by the hash index it is nil.
Ideas?

Here is the log output of the inspect hash:

{:has_key=0, :ext_array=[Text file (.txt)br/, Rich Text Format
(.rtf)br/, Word Document (.doc, .docx)br/]}

When I do:

h[:ext_array]  it is nil.

-- 
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: Re: Email using ruby on rails

2010-03-18 Thread Sandip Ransing
Hi Manish,

Is email sending log is getting created inside log file ?
Is tutorialspoint.com http://smtp.tutorialspoint.com is your domain ? If
yes, then where smtp setup has been done ?
Why don't you send emails using gmail account ?

Thanks,

On Wed, Mar 17, 2010 at 8:56 PM, Manish Belsare li...@ruby-forum.comwrote:

 You'll also want to change the address and domain to fit your
 needs. If you don't know, ask your IT department, or your ISP, or your
 webhost.



 Sir for your above mentioned thing well is it necessary to know the
 domain and address from my ISP??
 i cant send an email from my application without this..
 Also i would like to mention that the email information is displayed in
 the web server but it is not routed to the mentioned email address..so
 wat should i do?
 --
 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.comrubyonrails-talk%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.




-- 
Sandip

---
www.funonrails.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] Dynamic cookie domain (for multitenant app)

2010-03-18 Thread Alexey Petrushin
There is a Multitenant App, that should serve sites on domains like
this:
  client1.app.com
  client2.app.com
And it's easy to share cookies between all of them (using '.app.com'
cookie domain):
  ActionController::Base.session = {:key = thekey, :secret =
thesecret, :domain = '.app.com'}

But! There is one more requirement, those sites should be also avaliable
as:
  www.client1.com

So, in order to all this works the App should dynamically change the
cookie domain:
  xxx.app.com = .app.com
  www.xxx.com = .xxx.com or leave it blank

Google told me that there is one approach
http://codetunes.com/2009/04/17/dynamic-cookie-domains-with-racks-middleware/
but it doesn't works (Rails 2.3.5).

I also tried my own solution:

  class CrossDomainCookies
def initialize(app)
  @app = app
end

def call(env)
  host = env[HTTP_HOST].split(':').first.downcase
  if host.include?('.')
normalized_host = host.scan(/[^\.]+\.[^\.]+$/).first
cookie_domain = .#{normalized_host}
  else
normalized_host = host
cookie_domain = host
  end

  Rails.logger.info cookie_domain

  ActionController::Base.session_options['domain'] = cookie_domain

  @app.call(env)
end
  end

But it also doesn't works, maybe there are some other solutions?
-- 
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: rerender a page if validation fails

2010-03-18 Thread Tom Mac
Hi
   I get error when I enter   http://localhost:3000/users/1   from url

But if it is   http://localhost:3000/users/1/edit   No problem.
So my question is why in the else case it shows in the url

http://localhost:3000/users/1
  instead of
http://localhost:3000/users/1/edit


Tom






-- 
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.



Re: [Rails] Re: Re: Re: Re: refresh a page using AJAX?

2010-03-18 Thread Bala
Veena,

can you post the current_readings_list codes

i think you miss the point. when you call the partial file through
controller, you must pass the value through locals if the varaible is not
instance

something like this

page.replace_html :current_reading, :partial='current_readings_list',
:locals = {:id = params[:id]}




Thu, Mar 18, 2010 at 9:53 AM, Veena Jose li...@ruby-forum.com wrote:

 Hai Bala,

  I hav looked into the development.log file.I understood that the
 problem as in _current_readings_list it is not getting the id
 parameter based on which it has to display the readings.I dont know
 whether i am correct or not.

 I am attaching the development.log file.

 controller
  def show_readings_for_station
 @range=ConfigureParameter.find(:all)
if (params[:state] ==)
  @readings = CurrentReading.find(:all)
else
stations = Station.find_all_by_state(params[:state])
@readings = CurrentReading.find_all_by_station_id(stations,
 :order=station_id)
  end
 respond_to do |format|
  format.js
end #End of respond_to do block
  end #End of action show_readings_for_station

  def show_current_readings
   @range=ConfigureParameter.find(:all)
if (params[:state] ==)
  @readings = CurrentReading.find(:all)
else
stations = Station.find_all_by_state(params[:state])
@readings = CurrentReading.find_all_by_station_id(stations,
 :order=station_id)
end
render :update do |page|
  page.replace_html :current_reading,
 :partial='current_readings_list'
   page.visual_effect :highlight, 'current_reading'
end
  end

 index.html.erb

 % form_for :selected_district ,:url = {:action ='update',:id =
 @selected_district } do |f| %
   centerb %= f.label :Stations  %/b

 %= select(:selected_district,:state,
 @states,{:include_blank='All'},{:onchange
 =remote_function(:url=/readings/show_readings_for_station,:with
 ='state='+this.value)} )  %

 /center

 %end%
 div id=reading_list
 % form_tag  :action =details do %
  div id=current_reading
  # code here
  /div
  %= periodically_call_remote(:url = { :action=
 show_current_readings }, :frequency = 5)%
 %end%
 /div

 Can you plz tell me how can i get the id of the selected element in
 select tag to the action show_current_readings? If i am wrong plz do
 correct me..

 Thanks,
 Veena


 Attachments:
 http://www.ruby-forum.com/attachment/4596/development.log

 --
 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.comrubyonrails-talk%2bunsubscr...@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] Re: rerender a page if validation fails

2010-03-18 Thread Brijesh Shah
When you are click on submit to update the data, /users/1  url is called 
..


Now if your data is valid and saved properly then it will redirect to 
another page...

If your data is not valid or not saved properly then it will render to 
edit page..

When you render to any page , it will only call view page and url 
remains same,

benefit of render the page is that object contain the current data as 
well as the errors (if any which are use to show on page).



Thanks
Brijesh Shah
-- 
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.



Re: [Rails] Re: Re: Re: Re: refresh a page using AJAX?

2010-03-18 Thread Nitin Rajora
you need to include a option
,
:with='state='+document.getElementById('selected_district_state').value)

for your periodically call control..
%= periodically_call_remote(:url = { :action=show_current_readings },
:frequency = 5,
:with='state='+document.getElementById('selected_district_state').value)
%

I will send more hints later.
Nitin

On Thu, Mar 18, 2010 at 9:53 AM, Veena Jose li...@ruby-forum.com wrote:

 Hai Bala,

  I hav looked into the development.log file.I understood that the
 problem as in _current_readings_list it is not getting the id
 parameter based on which it has to display the readings.I dont know
 whether i am correct or not.

 I am attaching the development.log file.

 controller
  def show_readings_for_station
 @range=ConfigureParameter.find(:all)
if (params[:state] ==)
  @readings = CurrentReading.find(:all)
else
stations = Station.find_all_by_state(params[:state])
@readings = CurrentReading.find_all_by_station_id(stations,
 :order=station_id)
  end
 respond_to do |format|
  format.js
end #End of respond_to do block
  end #End of action show_readings_for_station

  def show_current_readings
   @range=ConfigureParameter.find(:all)
if (params[:state] ==)
  @readings = CurrentReading.find(:all)
else
stations = Station.find_all_by_state(params[:state])
@readings = CurrentReading.find_all_by_station_id(stations,
 :order=station_id)
end
render :update do |page|
  page.replace_html :current_reading,
 :partial='current_readings_list'
   page.visual_effect :highlight, 'current_reading'
end
  end

 index.html.erb

 % form_for :selected_district ,:url = {:action ='update',:id =
 @selected_district } do |f| %
   centerb %= f.label :Stations  %/b

 %= select(:selected_district,:state,
 @states,{:include_blank='All'},{:onchange
 =remote_function(:url=/readings/show_readings_for_station,:with
 ='state='+this.value)} )  %

 /center

 %end%
 div id=reading_list
 % form_tag  :action =details do %
  div id=current_reading
  # code here
  /div
  %= periodically_call_remote(:url = { :action=
 show_current_readings }, :frequency = 5)%
 %end%
 /div

 Can you plz tell me how can i get the id of the selected element in
 select tag to the action show_current_readings? If i am wrong plz do
 correct me..

 Thanks,
 Veena


 Attachments:
 http://www.ruby-forum.com/attachment/4596/development.log

 --
 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.comrubyonrails-talk%2bunsubscr...@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] Re: ruby array inside hash is nil.

2010-03-18 Thread Loganathan Ganesan
Chris Habgood wrote:
 I assign an array to a hash value.  When I inspect it shows the array
 but when I try to access the array by the hash index it is nil.
 Ideas?
 
 Here is the log output of the inspect hash:
 
 {:has_key=0, :ext_array=[Text file (.txt)br/, Rich Text Format
 (.rtf)br/, Word Document (.doc, .docx)br/]}
 
 When I do:
 
 h[:ext_array]  it is nil.

If u don't mind can u give me the whole 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-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] One-time script to update 1000s of values in a single column in a table: nil error?

2010-03-18 Thread Michael Pavling
On 18 March 2010 02:26, Clay H. cchea...@gmail.com wrote:
 Stock.rb
 ^
  self.strength = self.strength.gsub!(' ml', 'ml') if

The gsub bang method returns nil if no changes are made: it's a
method for changing string variables in place, not really for
assigning the return value (unless you're using the return value to
check whether any replacements were made.

Change to:
  self.strength = self.strength.gsub(' ml', 'ml') if...

-- 
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] ruby array inside hash is nil.

2010-03-18 Thread Michael Pavling
On 18 March 2010 06:18, Me chabg...@gmail.com wrote:
 I assign an array to a hash value.

 h[:ext_array]  it is nil.

I copied your hash into IRB and it worked fine:
 h = {:has_key=0, :ext_array=[Text file (.txt)br/, Rich Text Format
(.rtf)br/, Word Document (.doc, .docx)br/]}
= {:has_key=0, :ext_array=[Text file (.txt)br/, Rich Text
Format\n(.rtf)br/, Word Document (.doc, .docx)br/]}
 h[:ext_array]
= [Text file (.txt)br/, Rich Text Format\n(.rtf)br/, Word
Document (.doc, .docx)br/]


Can you post the code where you're accessing h[:ext_array] and getting
nil. I think you might be getting nil as the result of an expression
rather than the value from the hash.

-- 
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: rerender a page if validation fails

2010-03-18 Thread Harish
Hi Tom,

It is happening so because, when u clicked update, the browser had
sent post request to the new url which is http://localhost:3000/users/1
which is nothing but update action in ur controller. In ur update
action you are rendering the edit action if the validation failed.
Which means that url on browser doesn't change but the page being
viewed is still edit page. So when user clicks on the url and press
enter, it sends get request (not post request) to http://localhost:3000/users/1,
which actually invokes show action in your controller.

The browser behavior is actually normal and correct. If the user
clicks on the url and press enter, it should be assume that user wants
to see the data not edit.

So you actually need to define show action or redirect the user back
to edit page when validation fails (but redirecting will not carry
your validation error messages, so you may have to put some additional
efforts to carry those validation error messages).


On Mar 18, 10:34 am, Tom Mac li...@ruby-forum.com wrote:
 Hi
    I have in routes.rb like
 map.resources :users

         Now I am trying to edit a user. What the url shows now 
 ishttp://localhost:3000/users/1/edit
       But my problem is , when I click on update button and if
 validations fail I am re rendering the edit page.  And it happens
 properly. But the url becomes

 http://localhost:3000/users/1

            I can't figure it out . Please give a solution. Why this
 happens? So if a user goes to url and press enter it will show

 Unknown action

 No action responded to show. Actions: create, edit, new, and update

     My controller code for update is

   def update
     �...@user = User.find(params[:id])
       respond_to do |format|
   if @user.update_attributes(params[:user])
           flash[:notice] = 'User was successfully updated.'
           format.html { redirect_to home_url }
           format.xml  { head :ok }
         else
           flash.now[:error] = @user.errors.full_messages.join(br /)
           format.html { render :action = edit }
           format.xml  { render :xml = @user.errors, :status =
 :unprocessable_entity }
         end
       end
   end

 Thanks in advance
 Tom
 --
 Posted viahttp://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.



Re: [Rails] Re: rails+prawnto: setting :type to :prawn in a #render_to_string call not working

2010-03-18 Thread Michael Pavling
On 17 March 2010 23:05, Kendall Gifford zettab...@gmail.com wrote:
 Anyhow, if anyone also has any other good recommendations on how to
 keep controllers DRY when you need to do something like what I'm
 trying to do here, feel free to chime in.

I had a similar problem several weeks ago; I have lots of Prawnto
views and I needed to render one outside of the ERB (to generate a PDF
for an email file attachment).

In the end, I wrote some wholly ugly code to get around it:
http://www.workingwithrails.com/forums/4-ask-a-rails-expert/topics/804-send-dynamicly-generated-pdf-as-attachement
http://groups.google.com/group/prawn-ruby/browse_thread/thread/1859774668fc66a2

... my solution was certainly frowned on by the Prawn core; and
they're correct. It does seem that Prawnto causes more problems than
it solves by trying to be nice. If you follow the Prawn guides for
integrating with Rails, the process is a lot more re-useable.

But if you're in my position, and are stuck with loads of Prawnto
views you can't get rid of overnight, then the solution I've posted
will at least let you take their output and put it to different use.

-- 
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: require behaves differently in Rails vs vanilla Ruby?

2010-03-18 Thread Frederick Cheung


On Mar 17, 11:52 pm, Poco Ritard chris.abaj...@gmail.com wrote:
 but irb can't:

 [chr...@ibs-chrisa-ux1 lims_m6.6]$ irb
 irb(main):001:0 module AIBS::Hotfix::Logger
 irb(main):002:1 end
 NameError: uninitialized constant AIBS
         from (irb):1
 irb(main):003:0 [chr...@ibs-chrisa-ux1 lims_m6.6]$

 what's even weirder, instead of the a::b::c form, I nest them on
 different lines and voila:

That's not unexpected - the second form reopens (or creates) the AIBS
module, whereas writing AIBS::Hotfix::Logger requires the AIBS and
AIBS::Hotfix already exist. If they don't exist then const_missing is
hit. Rails hooks this to try and load AIBS from somewhere (as long as
there is a file named aibs.rb in one of the search paths this should
work), apparently succeeding, whereas the default implementation just
throws NameError


 This is all driven by a desire to use a bunch of (our) library code
 outside of the Rails framework i.e. for backend processing...

The easy way here is to require config/environment which loads up
rails for you. If you just want the const autoloading you can set that
up to but you'll have to delve into the Rails startup stuff to see how
it initializes stuff.

Fred

 Any pointers you could suggest that would help me get a grip on what's
 going on would be greatly appreciated.

 On Mar 17, 4:27 pm, Frederick Cheung frederick.che...@gmail.com
 wrote:




-- 
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: Re: Re: Email using ruby on rails

2010-03-18 Thread Manish Belsare

 Why don't you send emails using gmail account ?
 


Sir,
I would surely like to know what i have to make changes in the 
environment.rb file..
My email information is available in the development.log file..

Sir my environment.rb file has foll contents:

ActionMailer::Base.delivery_method = :smtp

ActionMailer::Base.smtp_settings = {
  :address = smtp.gmail.com ,
  :port = 25,
  :domain = gmail.com ,
  :authentication = :login,
  :enable_starttls_auto = true,
  :user_name = mukesh ,
  :password = 123456
}

Here user name is user name created by the user and not email id..
so what schanges chould i make to this file?


-- 
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: Re: Re: Re: Re: refresh a page using AJAX?

2010-03-18 Thread Veena Jose
Thank you soo much Nitin. Your thing has solved my problem
Now i am getting the id of the selected state to the 
periodically_call_remote()

Thank you Bala for giving so much of help
Thank you all.

Guys you are really great

Thanks,
Veena

-- 
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.



Re: [Rails] Re: Re: Re: Re: Re: refresh a page using AJAX?

2010-03-18 Thread Nitin Rajora
sure keep learning..
Nitin.

On Thu, Mar 18, 2010 at 3:02 PM, Veena Jose li...@ruby-forum.com wrote:

 Thank you soo much Nitin. Your thing has solved my problem
 Now i am getting the id of the selected state to the
 periodically_call_remote()

 Thank you Bala for giving so much of help
 Thank you all.

 Guys you are really great

 Thanks,
 Veena

 --
 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.comrubyonrails-talk%2bunsubscr...@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.



Re: [Rails] Re: Re: Re: Re: Re: refresh a page using AJAX?

2010-03-18 Thread Bala
welcome.

On Thu, Mar 18, 2010 at 3:04 PM, Nitin Rajora nitinr...@gmail.com wrote:

 sure keep learning..
 Nitin.


 On Thu, Mar 18, 2010 at 3:02 PM, Veena Jose li...@ruby-forum.com wrote:

 Thank you soo much Nitin. Your thing has solved my problem
 Now i am getting the id of the selected state to the
 periodically_call_remote()

 Thank you Bala for giving so much of help
 Thank you all.

 Guys you are really great

 Thanks,
 Veena

 --
 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.comrubyonrails-talk%2bunsubscr...@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.comrubyonrails-talk%2bunsubscr...@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] Records created while tests are running are not being saved.

2010-03-18 Thread Vikrant Chaudhary
In following code -

require test_helper
Class SomeControllerTest  ActionController::TestCase

  def test_something
record = SomeModel.create :name = 'test'
record.save!
gets
  end

end

Above record is not being saved in the database. I can confirm this by
pausing execution by calling gets() and doing a SELECT * FROM
some_models right into the test database which returns no rows.

-- 
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] Records created while tests are running are not being saved.

2010-03-18 Thread Steven Hilton
On Thu, Mar 18, 2010 at 6:08 AM, Vikrant Chaudhary nas...@gmail.com wrote:
 In following code -

 require test_helper
 Class SomeControllerTest  ActionController::TestCase

  def test_something
    record = SomeModel.create :name = 'test'
    record.save!
    gets
  end

 end

 Above record is not being saved in the database. I can confirm this by
 pausing execution by calling gets() and doing a SELECT * FROM
 some_models right into the test database which returns no rows.

 --

Tests are ran inside a transaction and are rolled back after each
test. In a separate process (i.e. ./script/dbconsole) you will not see
the data create from a test, even if you pause execution.

You *should* be able to see the insert (and the roll back) happening in test.log

Even though the transaction is rolled back, the sequence on the
primary key is still advanced, so you should see that effect in a
separate process.

- Steven

-- 
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: Re: Re: Email using ruby on rails

2010-03-18 Thread Sandip Ransing
Just remove domain from smtp settings and it should work fine Instead we are
passing it through username.

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
  :address = smtp.gmail.com,
  :port = 587,
  :authentication = :plain,
  :enable_starttls_auto = true,
  :user_name = muk...@gmail.com,
  :password = 123456
}

Let me know if still problem!

On Thu, Mar 18, 2010 at 2:37 PM, Manish Belsare li...@ruby-forum.comwrote:


  Why don't you send emails using gmail account ?
 


 Sir,
 I would surely like to know what i have to make changes in the
 environment.rb file..
 My email information is available in the development.log file..

 Sir my environment.rb file has foll contents:

 ActionMailer::Base.delivery_method = :smtp

 ActionMailer::Base.smtp_settings = {
  :address = smtp.gmail.com ,
   :port = 25,
  :domain = gmail.com ,
  :authentication = :login,
  :enable_starttls_auto = true,
  :user_name = mukesh ,
  :password = 123456
 }

 Here user name is user name created by the user and not email id..
 so what schanges chould i make to this file?


 --
 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.comrubyonrails-talk%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.




-- 
Sandip

---
www.funonrails.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] method_missing

2010-03-18 Thread eugenio
i'm using method_missing to implement a simple metaprogramming that
checks for account rights.

in Account  ActiveRecord::Base i defined:

def method_missing(m, a = {})
  if m.to_s =~ /^has_right_(.*)$/
  ... calls another method passing $1 parameter
  end
end

it seems to override some of the active record methods based on method
missing. in the console it seems to work ok so i got some problem in
debugging.

how can i call from Account#method_missing the
activeRecord::Base#method_missing ?

-- 
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] REST and security ...

2010-03-18 Thread Pasalic Zaharije
Hi

we are creating small site on Rails which fits perfectly into REST
model. One of our futures is security model with roles. In general,
there are 3 types of users: standard, power-user and administrator. We
need also to have different admin users with different roles. Also in
other hand some users can have API access via RESTFUL interface.

Currently we are having standard CRUD interface via rest , something
similar to scaffold generated code:

def index
 @data = SomeCodeWhichLoadData()
 respond_to do |format|
format.html # index.html.erb
format.xml  { render :xml = @profiles }
 end
end

My problem is that i need to have standard rights (is user loged in),
plus rights to check if user can have access to html parts (admin v.s.
user v.s. power-user) and also part where i can limit some REST API to
some users.

Is there any standard (Rails) way for doing this? Any ideas how to fit
user rights model into rails app?

Best

-- 
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] method_missing

2010-03-18 Thread Michael Pavling
On 18 March 2010 10:23, eugenio eugenio.mode...@gmail.com wrote:
 i'm using method_missing to implement a simple metaprogramming that
 checks for account rights.

 it seems to override some of the active record methods based on method
 missing. in the console it seems to work ok so i got some problem in
 debugging.

This explains part of the problem:
http://ruby.tie-rack.org/6/safely-overriding-method_missing-in-a-class-that-already-has-it/

Calling to super should be part of your solution...
def method_missing(m, *args, block)
 if m.to_s =~ /^has_right_(.*)$/
 ... calls another method passing $1 parameter
 else
  super(m, *args, block)
 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-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] REST and security ...

2010-03-18 Thread Michael Pavling
On 18 March 2010 10:30, Pasalic Zaharije pasalic.zahar...@gmail.com wrote:
 Is there any standard (Rails) way for doing this? Any ideas how to fit
 user rights model into rails app?

Googling for rails role based permissions will give you several
articles discussing this problem.
The solution seems to be a) to roll your own, or b) use Aegis (or the
newer CanCan) to handle it for you.

I'm using Aegis in my main current project, in combination with
Clearance for authentication, but reading the CanCan docs, I'm very
tempted to use that next time as 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] Asking about ROR site

2010-03-18 Thread Saya Kurt
Hello guys,

I wonder what is the core used in storenvy.com and bigcartel.com ?

Or those site is just build from the scratch? Im planning to build site
that have similar functions.. maybe anyone can tell me what is the core
used in those site. Insoshi, spree or what?

thanks guys
-tenuxx-
-- 
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: method_missing

2010-03-18 Thread eugenio
#i added this line:
alias_method :ar_method_missing, :method_missing

#and an else condition in my method_missing

def method_missing(m,*a,block)
  if m.to_s =~ /^has_right_(.*)$/
  ... calls another method passing $1 parameter
  else
  ar_method_missing(m,*a, block)
  end
end

it seems to work now.

On 18 Mar, 11:23, eugenio eugenio.mode...@gmail.com wrote:
 i'm using method_missing to implement a simple metaprogramming that
 checks for account rights.

 in Account  ActiveRecord::Base i defined:

 def method_missing(m, a = {})
   if m.to_s =~ /^has_right_(.*)$/
   ... calls another method passing $1 parameter
   end
 end

 it seems to override some of the active record methods based on method
 missing. in the console it seems to work ok so i got some problem in
 debugging.

 how can i call from Account#method_missing the
 activeRecord::Base#method_missing ?

-- 
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] capitalize and utf8 international symbols

2010-03-18 Thread Alex Shulgin
Hi there,

Being a relatively happy Rails user I suddenly noticed that
string#capitalize and friends do not play well with international
characters well.  Sample console session:

$ ./script/console
Loading development environment (Rails 2.2.3)
 $KCODE
= UTF8
 яблоко.capitalize
= яблоко

Where Яблоко was expected (Russian word for Apple).

I've googled for a workaround and found this:

 яблоко.mb_chars.capitalize.to_s
= Яблоко

but does it really need to be so ugly?  Everyone else doing this?

I'm on Ubuntu 9.10 with Rails-2.2.3 and ruby-1.8.7.

--
Cheers,
Alex

-- 
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: method_missing

2010-03-18 Thread Xavier Noria
On Thu, Mar 18, 2010 at 12:12 PM, eugenio eugenio.mode...@gmail.com wrote:

 #i added this line:
 alias_method :ar_method_missing, :method_missing

 #and an else condition in my method_missing

 def method_missing(m,*a,block)
  if m.to_s =~ /^has_right_(.*)$/
      ... calls another method passing $1 parameter
  else
      ar_method_missing(m,*a, block)
  end
 end

 it seems to work now.

Please don't do that.

This is ordinary object-oriented programming. If you override a method
and want to delegate to the parent just call super. That's what super
is for. Aliasing is an inappropriate solution to 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-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: Re: Re: Rails 3 Routing: Namespace'd Controllers?

2010-03-18 Thread Stefan Buhr
Conrad Taylor wrote:
 Sent from my iPhone
 
 
 Please post the Rails 2.x route that you would like to convert to
 Rails 3.0?
 

Hey Conrad,

I think I made a mistake.

I was under the impression that following code in rails 2
map.namespace :admin do |admin|
  admin.connect ':controller/:action/:id'
end
was enabling /admin/any_controller/any_action = 
Addmin::AnyController#any_action
but it did not.

instead, the default root was still enabled. The above code never 
worked.

Ultimatly, what I am trying to do, is to use the default root but ONLY 
for controllers in a specific namespace (other parts of the application 
are using resources)
-- 
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] Sending mail using action mailer

2010-03-18 Thread Saravanan Doraiswamy
Hi everyone,

I am new to ruby and i just wanna send an email using ruby action
mailer. i have been trying it for about a day. Not achieved. so many
replies came in from google but many were beating the bushes ..

can any one send me a correct procedure..

regards

ds
-- 
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.



Re: [Rails] ERROR NoMethodError: private method `gsub!' called

2010-03-18 Thread Colin Law
On 18 March 2010 04:29, Chris Mentch li...@ruby-forum.com wrote:
 I have just upgraded to Ruby 1.8.7 and Rails 2.2.2.  My previous project
 was at Ruby 1.8.6 and Rails 2.0.2.  My platform is Windows and Webrick
 for development.

 When I run Webrick, the server starts without error, the application
 runs, database connections work and I can click through the pages and
 display data.  But it does not serve any stylesheets or javascript
 files.  What's interesting is that images are displayed.  In the log
 file, I get a 500 error after it attempts to retrieve a stylesheet or
 javascript.  This occurs everytime.

 Example of attempt to retrieve prototype.js (a 500 error):
 -
 127.0.0.1 - - [17/Mar/2010:23:52:52 Eastern Daylight Time] GET
 /javascripts/pro
 totype.js?1268882775 HTTP/1.1 500 338
 Referer - /javascripts/prototype.js?1268882775
 [2010-03-17 23:52:52] ERROR NoMethodError: private method `gsub!' called
 for #Class:0x44ee480

Can you show us the rest of the error trace.

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 at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: ERROR NoMethodError: private method `gsub!' called

2010-03-18 Thread Colin Law
On 18 March 2010 04:49, Chris Mentch li...@ruby-forum.com wrote:

 Chris, when you switched your app from 2.0.2 to 2.3.5, did you run
 'rake rails:update' in the root of your project?

 -Conrad

 It was to 2.2.2 and, yes, I did run 'rake rails:update'.  Not sure if it
 did anything.  It didn't give any output and returned to the command
 prompt.

You can tell whether it changed anything by checking your current
version against the version in your version control repository.  If
you are not using one (git for example) start by setting one up.  When
messing about upgrading rails and so on you need to be able to track
what you have done, revert experimental changes, and so on.  A day or
two spent learning git will be recovered very quickly.

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 at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] how to disable a drop down list after selecting one value

2010-03-18 Thread Colin Law
On 18 March 2010 05:30, Tony Augustine li...@ruby-forum.com wrote:
 my  question is i  have  a  drop down list to  choose  some vales from
 an  xml file.after selecting one vaale  and  saving  it will b   saved.
 but  when i tried to edit that  it should  be   disabled. can any one
 provide  solutions

 this  is ma code fragment

        = f.select :name_type, Setting.unroll(:name_type), { :selected
 = (@name.name_type || mathew).to_sym }, { :style =
 width:300px,:disabled = true }

 here name_type is  the  name  of variable declared in  d  xml file with
 that  names.so  what  should b  code    4  disabled

Assuming there are separate views for new and edit then just disable
it in the edit view.

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 at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: REST and security ...

2010-03-18 Thread Sharagoz --
Michael Pavling wrote:
 On 18 March 2010 10:30, Pasalic Zaharije pasalic.zahar...@gmail.com 
 wrote:
 Is there any standard (Rails) way for doing this? Any ideas how to fit
 user rights model into rails app?
 
 Googling for rails role based permissions will give you several
 articles discussing this problem.
 The solution seems to be a) to roll your own, or b) use Aegis (or the
 newer CanCan) to handle it for you.
 
 I'm using Aegis in my main current project, in combination with
 Clearance for authentication, but reading the CanCan docs, I'm very
 tempted to use that next time as it.

Declarative Authorization is another good option
-- 
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: Sending mail using action mailer

2010-03-18 Thread Loganathan Ganesan
Saravanan Doraiswamy wrote:
 Hi everyone,
 
 I am new to ruby and i just wanna send an email using ruby action
 mailer. i have been trying it for about a day. Not achieved. so many
 replies came in from google but many were beating the bushes ..
 
 can any one send me a correct procedure..
 
 regards
 
 ds

Refer the below URL:
http://ruby-doc.org/stdlib/libdoc/net/smtp/rdoc/index.html

At the starting of the page itself, an example code is given for sending 
mail.
-- 
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] Testing best practice

2010-03-18 Thread Rails Fun
so what is the best way test bed to use for a rails project?

i'm thinking of using Rspec and Cucumber, but where do you do the unit tests? 
in Rspec?


  

-- 
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] Production Mode.. One liner question

2010-03-18 Thread Hemant Bhargava
Hello Champs,

Just a one liner question. I have written a script to put data into
production database. Where to execute that script ?
-- 
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] ActiveMerchant unit tests

2010-03-18 Thread Commander Johnson
Hi,

I'm testing my ActiveMerchant plugin installation with the iDeal payment
method. One test keeps failing even though I've inserted all the
credentials. The other test file, remote_ideal_test.rb, completes 100% of
the tests with the same credentials.

Any thoughts on this error?

Best regards,
CmdJohnson

---

Loaded suite
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
F.
Finished in 2.967798 seconds.

  1) Failure:
test_posts_data_with_ssl_to_acquirer_url_and_return_the_correct_response(IdealTestCases::GeneralTest)
[./test/unit/../../lib/active_merchant/billing/gateways/ideal.rb:327:in
`post_data'
 ./test/unit/gateways/ideal_test.rb:130:in `send'
 ./test/unit/gateways/ideal_test.rb:130:in
`test_posts_data_with_ssl_to_acquirer_url_and_return_the_correct_response']:
unexpected invocation:
ActiveMerchant::Billing::IdealResponse.new('response', {:test = false})
unsatisfied expectations:
- expected exactly once, not yet invoked:
ActiveMerchant::Billing::IdealResponse.new('response', {:test = true})
satisfied expectations:
- expected exactly once, already invoked once:
#ActiveMerchant::Billing::IdealGateway:0x7f1d474d7d88.ssl_post('
https://ideal.secure-ing.com:443/ideal/iDeal', 'data')

690 tests, 2026 assertions, 1 failures, 0 errors
rake aborted!
Command failed with status (1): [/usr/bin/ruby1.8 -Ilib -rubygems
/usr/l...]

(See full trace by running task with --trace)

-- 
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] One-time script to update 1000s of values in a single column in a table: nil error?

2010-03-18 Thread Colin Law
On 18 March 2010 02:26, Clay H. cchea...@gmail.com wrote:
 Hi, I have a model called Stock with a value called strength. I
 wrote a simple method in the Stock.rb model file to update the value
 of strength for each record in the stocks table. I created a
 controller called fix_controller.rb. I don't have access to the live
 system, so the idea is that an admin will go to http://url/fix and a
 script will run to check and potentially update the strength value
 for every record in the stocks table.
...

 I'm sure this is a simple error and/or I'm not going about this the
 correct way. I really only need to run this code once... Any idea why
 I'm getting that error? I'm checking for nil...

As you only need to run this once it might be better as a database migration

If you leave it as an action it should really be a POST.  Otherwise
google may come along and 'fix' it for you while scanning your site.

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 at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: how to disable a drop down list after selecting one value

2010-03-18 Thread Tony Augustine
Colin Law wrote:
 On 18 March 2010 05:30, Tony Augustine li...@ruby-forum.com wrote:

 here name_type is �the �name �of variable declared in �d �xml file with
 that �names.so �what �should b �code � �4 �disabled
 
 Assuming there are separate views for new and edit then just disable
 it in the edit view.
 
 Colin

no  one  view  for  both
-- 
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: Sending mail using action mailer

2010-03-18 Thread Bigos
if it is not enough, look for clues in log files in railsapp/log
making sure you check logs relevant to mode you run your app, eg.
development.log
if there's nothing there you need to configure your railss application
to send mails and report errors.

My railsapp/config/environments/development.rb also has following

config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :sendmail 

As regards delivery_method it might be different on your system if you
don't have email server installed on it.
You can find documentation how to configure rails to use googlemail,
so it should be easy to adapt it to your needs

Hope it helps.

Jacek

On 18 Mar, 11:53, Loganathan Ganesan li...@ruby-forum.com wrote:
 Saravanan Doraiswamy wrote:
  Hi everyone,

  I am new to ruby and i just wanna send an email using ruby action
  mailer. i have been trying it for about a day. Not achieved. so many
  replies came in from google but many were beating the bushes ..

  can any one send me a correct procedure..

  regards

  ds

 Refer the below URL:http://ruby-doc.org/stdlib/libdoc/net/smtp/rdoc/index.html

 At the starting of the page itself, an example code is given for sending
 mail.
 --
 Posted viahttp://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: One-time script to update 1000s of values in a single column in a table: nil error?

2010-03-18 Thread Clay H.
What exactly does the ...in place part of that mean?

On Mar 18, 4:42 am, Michael Pavling pavl...@gmail.com wrote:
 On 18 March 2010 02:26, Clay H. cchea...@gmail.com wrote:

  Stock.rb
  ^
   self.strength = self.strength.gsub!(' ml', 'ml') if

 The gsub bang method returns nil if no changes are made: it's a
 method for changing string variables in place, not really for
 assigning the return value (unless you're using the return value to
 check whether any replacements were made.

 Change to:



   self.strength = self.strength.gsub(' ml', 'ml') if...

-- 
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: how to disable a drop down list after selecting one value

2010-03-18 Thread Colin Law
On 18 March 2010 12:04, Tony Augustine li...@ruby-forum.com wrote:
 Colin Law wrote:
 On 18 March 2010 05:30, Tony Augustine li...@ruby-forum.com wrote:

 here name_type is �the �name �of variable declared in �d �xml file with
 that �names.so �what �should b �code � �4 �disabled

 Assuming there are separate views for new and edit then just disable
 it in the edit view.

 Colin

 no  one  view  for  both

If you are using the same view for both how does the view know whether
to submit a create or an update action?

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 at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Sending mail using action mailer

2010-03-18 Thread Saravanan Doraiswamy
Hi,

In this mean time, i downloaded a youtube video and followed the 
procedure, now i am getting this error :

E:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:105:in
 
`const_missing'
E:/Users/Jithu/RubyMails/gmailer/app/controllers/notifications_controller.rb:3:in
 
`create'

can you help me get out of this

regards,

ds

Loganathan Ganesan wrote:
 Saravanan Doraiswamy wrote:
 Hi everyone,
 
 I am new to ruby and i just wanna send an email using ruby action
 mailer. i have been trying it for about a day. Not achieved. so many
 replies came in from google but many were beating the bushes ..
 
 can any one send me a correct procedure..
 
 regards
 
 ds
 
 Refer the below URL:
 http://ruby-doc.org/stdlib/libdoc/net/smtp/rdoc/index.html
 
 At the starting of the page itself, an example code is given for sending 
 mail.

-- 
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.



Re: [Rails] Production Mode.. One liner question

2010-03-18 Thread Xavier Noria
On Thu, Mar 18, 2010 at 1:00 PM, Hemant Bhargava li...@ruby-forum.com wrote:

 Just a one liner question. I have written a script to put data into
 production database. Where to execute that script ?

For scripts sometimes I create a bin directory. Those are run with
script/runner.

-- 
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] MailChimp API recommendations?

2010-03-18 Thread Hassan Schroeder
This page - http://www.mailchimp.com/api/downloads/ - lists five
gems/plugins for interacting with the MailChimp service, and for all
I know there are others.

Anyone have a personal recommendation? Based on any of stability,
ease of integration, completeness, whatever...

TIA,
-- 
Hassan Schroeder  hassan.schroe...@gmail.com
twitter: @hassan

-- 
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: One-time script to update 1000s of values in a single column in a table: nil error?

2010-03-18 Thread Michael Pavling
On 18 March 2010 12:18, Clay H. cchea...@gmail.com wrote:
 What exactly does the ...in place part of that mean?

 On Mar 18, 4:42 am, Michael Pavling pavl...@gmail.com wrote:
 The gsub bang method returns nil if no changes are made: it's a
 method for changing string variables in place, not really for
 assigning the return value (unless you're using the return value to
 check whether any replacements were made.

If you assign a value to a variable:

   my_variable = 100 mg
you can alter the variable using the bang method without using an =
operator to assign
so :
   my_variable = my_variable.gsub(' mg', 'mg')
is the same as:
   my_variable.gsub!(' mg', 'mg')
but beware of:
   my_variable = my_variable.gsub!(' mg', 'mg')
as if no substitution is made, the new value of my_variable will be
nil (as you discovered ;-)

http://ruby-doc.org/core/classes/String.html#M000817

-- 
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] how to disable a drop down list after selecting one value

2010-03-18 Thread Andy Jeffries

 this  is ma code fragment

= f.select :name_type, Setting.unroll(:name_type), { :selected
 = (@name.name_type || mathew).to_sym }, { :style =
 width:300px,:disabled = true }

 here name_type is  the  name  of variable declared in  d  xml file with
 that  names.so  what  should b  code4  disabled


Try:

 = f.select :name_type, Setting.unroll(:name_type), { :selected
= (@name.name_type || mathew).to_sym }, { :style =
width:300px,:disabled = !...@name.new_record? }

Cheers,


Andy

-- 
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] hash in controller is nil after submitting form

2010-03-18 Thread ES
I'm trying to create a data entry form but getting an error when it
sumbmits.  I am using an hash to get the names of the fields definied
in the controller's new function:

  def new
@thing = thing.new
@columns = Hash.new

@columns['thing_general'] = [
[title,name],
[number,num],

   etc...

and then I access it in the object's new.html.erb:

  % for c in @columns['thing_general'] do %
 tr
   td class=name
   label for=%=c.first%%=c.first%/label/td
   td
   input id=%=c.second% name=thing[%=c.second
%]type=text //td
   /td

the first time I load the page, the correct form displays but then
when I click submit, I get this error :

You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]

Extracted source (around line #38):

35:   trtdhr//td/tr
36:
37:   tbody
38:% for c in @columns['thing_general'] do %
39:  tr
40:td class=name
41:label for=%=c.first%%=c.first%/label/td



why would it get a nil object when I submit the form (after working
the first time) and why is it trying to load the same page after
submitting?

-- 
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] hash in controller is nil after submitting form

2010-03-18 Thread Michael Pavling
On 18 March 2010 13:43, ES emsto...@gmail.com wrote:
 the first time I load the page, the correct form displays but then
 when I click submit, I get this error :

 You have a nil object when you didn't expect it!
 You might have expected an instance of ActiveRecord::Base.
 The error occurred while evaluating nil.[]

 why would it get a nil object when I submit the form (after working
 the first time) and why is it trying to load the same page after
 submitting?

When you click submit, you're probably going through the create
method (unless you've set the form to go somewhere else)... does the
@columns['thing_general'] value get populated there (you've shown the
code for the new method, but not create)?

-- 
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] hash in controller is nil after submitting form

2010-03-18 Thread Colin Law
On 18 March 2010 13:43, ES emsto...@gmail.com wrote:
 I'm trying to create a data entry form but getting an error when it
 sumbmits.  I am using an hash to get the names of the fields definied
 in the controller's new function:

  def new
   �...@thing = thing.new
   �...@columns = Hash.new

   �...@columns['thing_general'] = [
            [title,name],
            [number,num],

   etc...

 and then I access it in the object's new.html.erb:

  % for c in @columns['thing_general'] do %
     tr
       td class=name
       label for=%=c.first%%=c.first%/label/td
       td
       input id=%=c.second% name=thing[%=c.second
 %]type=text //td
       /td

 the first time I load the page, the correct form displays but then
 when I click submit, I get this error :

 You have a nil object when you didn't expect it!
 You might have expected an instance of ActiveRecord::Base.
 The error occurred while evaluating nil.[]

 Extracted source (around line #38):

 35:   trtdhr//td/tr
 36:
 37:   tbody
 38:    % for c in @columns['thing_general'] do %
 39:      tr
 40:        td class=name
 41:        label for=%=c.first%%=c.first%/label/td



 why would it get a nil object when I submit the form (after working
 the first time) and why is it trying to load the same page after
 submitting?

I presume that when you click it is calling a controller action, then
for whatever reason rendering the page again, but this time @columns
is not setup, hence the error.  Have a look at the action called by
the submit and see what you have told it to do.  Also have a look in
development.log and you may get a clue.  Guessing at what the code may
do, possibly the submit requests a save that fails so you are
re-rendering the page to allow the user to make a correction, but you
have not setup @columns.

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 at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: hash in controller is nil after submitting form

2010-03-18 Thread ES
yes I am going through create, should I make the @columns hash a class
variable or just repopulate it in the create method?

On Mar 18, 2:49 pm, Michael Pavling pavl...@gmail.com wrote:
 On 18 March 2010 13:43, ES emsto...@gmail.com wrote:

  the first time I load the page, the correct form displays but then
  when I click submit, I get this error :

  You have a nil object when you didn't expect it!
  You might have expected an instance of ActiveRecord::Base.
  The error occurred while evaluating nil.[]

  why would it get a nil object when I submit the form (after working
  the first time) and why is it trying to load the same page after
  submitting?

 When you click submit, you're probably going through the create
 method (unless you've set the form to go somewhere else)... does the
 @columns['thing_general'] value get populated there (you've shown the
 code for the new method, but not create)?

-- 
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: hash in controller is nil after submitting form

2010-03-18 Thread Michael Pavling
On 18 March 2010 13:53, ES emsto...@gmail.com wrote:
 yes I am going through create, should I make the @columns hash a class
 variable or just repopulate it in the create method?

You can do it however you like; you just need to make sure it's not nil ;-)

Personally... I would make a decision based on the object and the purpose:
 - I *doubt* it's really likely to be best as a class variable
 - repopulate it if that's easiest, but consider refactoring the
population out to a private method to reuse it
 - Could it be that this variable may really make more sense as a constant?
 - Maybe other factors come into play that aren't evident from your posting...

To be honest... I'm not sure I like the idea of the controller telling
the view which fields to display - maybe this functionality would be
better off in a view helper - but that's a different conversation, and
it's your code :-/

-- 
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: hash in controller is nil after submitting form

2010-03-18 Thread Colin Law
On 18 March 2010 13:53, ES emsto...@gmail.com wrote:
 yes I am going through create, should I make the @columns hash a class
 variable or just repopulate it in the create method?

You could populate it in a before or after_filter on those actions.  I
have to say that the whole thing looks a bit odd.  Are you sure it
should not be in a view helper for example?

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 at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Testing best practice

2010-03-18 Thread Rick DeNatale
On Thu, Mar 18, 2010 at 7:57 AM, Rails Fun rails...@yahoo.com wrote:
 so what is the best way test bed to use for a rails project?
 i'm thinking of using Rspec and Cucumber, but where do you do the unit
 tests? in Rspec?

Yes

-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

-- 
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: hash in controller is nil after submitting form

2010-03-18 Thread ES
hmmm, I'm totally new to this, what exactly is a helper used for?  For
these kinds of constant-type things in a view?

On Mar 18, 3:08 pm, Colin Law clan...@googlemail.com wrote:
 On 18 March 2010 13:53, ES emsto...@gmail.com wrote:

  yes I am going through create, should I make the @columns hash a class
  variable or just repopulate it in the create method?

 You could populate it in a before or after_filter on those actions.  I
 have to say that the whole thing looks a bit odd.  Are you sure it
 should not be in a view helper for example?

 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 at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: hash in controller is nil after submitting form

2010-03-18 Thread Colin Law
On 18 March 2010 14:16, ES emsto...@gmail.com wrote:
 hmmm, I'm totally new to this, what exactly is a helper used for?  For
 these kinds of constant-type things in a view?

This is a reasonable introduction -
http://paulsturgess.co.uk/articles/show/49-using-helper-methods-in-ruby-on-rails

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 at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: hash in controller is nil after submitting form

2010-03-18 Thread ES
ok, thanks!

On Mar 18, 3:24 pm, Colin Law clan...@googlemail.com wrote:
 On 18 March 2010 14:16, ES emsto...@gmail.com wrote:

  hmmm, I'm totally new to this, what exactly is a helper used for?  For
  these kinds of constant-type things in a view?

 This is a reasonable introduction 
 -http://paulsturgess.co.uk/articles/show/49-using-helper-methods-in-ru...

 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 at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Problem with db:test:prepare

2010-03-18 Thread Thiel Chang

Hi,

I am learning Rails from Agile Web Development with Rails (third 
edition) by implementing the Depot example. This is an excellent book to 
learn Rails.


However, I have a problem in the chapter 14, Testing, in which I had to 
run the command: db:test:prepare. It gave the following result;


 in C:/MyProjects/dev/webshop)
 rake aborted!
 Task not supported by 'jdbcmysql'
 rake aborted!
 invalid meta-code syntax: /C:\MyProjects\dev\webshop\Rakefile/

I am using the Netbeans 6.8 IDE with WeBrick as the application server.

Can anyone give me a clue how to solve that problem?

Thanks in advance,

Thiel

--
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: When -exactly- does the Rails3 application get initialized?

2010-03-18 Thread Bob Martens
Anyone else with this? I'm running into a similar situation with
CarrierWave where during initialization (using unicorn for testing) I
can't get it to load because Rails.root is nil and they can't join nil
with a string.

Any help here would be greatly appreciated. How have others got around
this?

On Mar 12, 10:39 am, ChrisT ccth...@gmail.com wrote:
 I've been fighting left and right with rails 3 and bundler. There are
 a few gems out there that don't work properly if the rails application
 hasn't been loaded yet. factory_girl and shoulda are both examples,
 even on the rails3 branch. Taking shoulda as an example, when trying
 to run rake test:units I get the following error:
 DEPRECATION WARNING: RAILS_ROOT is deprecated! UseRails.rootinstead.
 (called from autoload_macros at c:/code/test_harness/vendor/
 windows_gems/gems/shoulda-2.10.3/lib/shoulda/autoload_macros.rb:40) c:/
 code/test_harness/vendor/windows_gems/gems/shoulda-2.10.3/lib/shoulda/
 autoload_macros.rb:44:in 'join': can't convert #Class:0x232b7c0 into
 String (TypeError) from c:/code/test_harness/vendor/windows_gems/gems/
 shoulda-2.10.3/lib/shoulda/autoload_macros.rb:44:in 'block in
 autoload_macros' from c:/code/test_harness/vendor/windows_gems/gems/
 shoulda-2.10.3/lib/shoulda/autoload_macros.rb:44:in 'map' from c:/code/
 test_harness/vendor/windows_gems/gems/shoulda-2.10.3/lib/shoulda/
 autoload_macros.rb:44:in 'autoload_macros' from c:/code/test_harness/
 vendor/windows_gems/gems/shoulda-2.10.3/lib/shoulda/rails.rb:17:in
 'top (required)'

 Digging a bit deeper into lib/shoulda/rails, I see this:
 root = if defined?(Rails.root) Rails.rootRails.root
 else
 RAILS_ROOT
 end
 # load in the 3rd party macros from vendorized plugins and gems
 Shoulda.autoload_macros root, File.join(vendor, {plugins,gems},
 *)

 So...what's happening here is whileRails.rootis defined,Rails.root
 == nil, so RAILS_ROOT is used, and RAILS_ROOT==nil, which is then
 being passed on to Shoulda.autoload_macros. Obviously the rails app
 has yet to be initialized. With Rails3 using Bundler now, there's been
 some hubub over on the Bundler side about being able to specify an
 order in which the gems are required, but I'm not sure whether or not
 this would solve the problem at hand.
 Ultimately my questions is this: When exactly does the environment.rb
 file (which actually initializes the application) get pulled in? Is
 there any harm to bumping up when the app is initialized and have it
 happen before the Bundler.require line in config/application.rb? I've
 tried to hack bundler to specify the order myself, and have the rails
 gem pulled in first, but it doesn't appear to me that requiring the
 rails gem actually initializes the application.
 As this line (in config/application.rb) is being called before the app
 is initialized, any gem in the bundler Gemfile that requires rails to
 be initialized is going to tank.

 # Auto-require default libraries and those for the current Rails
 environment. Bundler.require :default, Rails.env

-- 
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: Records created while tests are running are not being saved.

2010-03-18 Thread Vikrant Chaudhary
Thanks.

On Mar 18, 3:13 pm, Steven Hilton mshilt...@gmail.com wrote:
 On Thu, Mar 18, 2010 at 6:08 AM, Vikrant Chaudhary nas...@gmail.com wrote:
  In following code -

  require test_helper
  Class SomeControllerTest  ActionController::TestCase

   def test_something
     record = SomeModel.create :name = 'test'
     record.save!
     gets
   end

  end

  Above record is not being saved in the database. I can confirm this by
  pausing execution by calling gets() and doing a SELECT * FROM
  some_models right into the test database which returns no rows.

  --

 Tests are ran inside a transaction and are rolled back after each
 test. In a separate process (i.e. ./script/dbconsole) you will not see
 the data create from a test, even if you pause execution.

 You *should* be able to see the insert (and the roll back) happening in 
 test.log

 Even though the transaction is rolled back, the sequence on the
 primary key is still advanced, so you should see that effect in a
 separate process.

 - Steven

-- 
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] HABTM Associations In View

2010-03-18 Thread Andy
Hello,
I wish I had the time to figure this out but I'm on a limited timeline
to convince people to look at RoR instead of Drupal, so I need to get
something relatively simple working fast. Any help or pointers would
be appreciated!

I have two HABTM many models, recipe_item and purchase_item. I need a
form to designate in my view that any number of purchase_items or
recipe_items can be a component of a given recipe_item. It looks like
Ryan Bates' screencast on nested model forms provides a lot of help on
a similar issue, but I'm having trouble picking apart the logic for my
issue. Regardless at the moment as a test I'm just trying to get a
single select on the recipe_item view to submit the purchase_item
association. When I submit I get this error:

PurchaseItem(#20112400) expected, got Array(#102050)

Here is my code:

Models:

class PurchaseItem  ActiveRecord::Base
  has_and_belongs_to_many :recipe_items
end

class RecipeItem  ActiveRecord::Base
  has_and_belongs_to_many :purchase_items
end

Controllers are left completely as generated by 2.3 Rails scaffolding.

New recipe_item View:

h1New recipe_item/h1

% form_for(@recipe_item) do |f| %
  %= f.error_messages %

  p
%= f.label :name %br /
%= f.text_field :name %
  /p
p
% f.fields_for :purchase_items do |n| %
%= n.label :purchase_item_id %
%= n.select :purchase_item_id, 
PurchaseItem.all.collect {|a|
[a.name, a.id] }%
% end %
/p
  p
%= f.submit 'Create' %
  /p
% end %

%= link_to 'Back', recipe_items_path %


I'm aware this can be DRYed up but like I said right now I just need
to demonstrate something working for my team. Any help would be
appreciated!

Thanks,
Andy

-- 
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] RJS error: TypeError: element is null

2010-03-18 Thread Salil Gaikwad
Hi All,

I got RJS error: TypeError: element is null while using ajax.

I used  in view

%= periodically_call_remote(:url={:action='get_user_list', :id='1'},
:frequency = '5') %

in controller

  render :update do |page|
page.replace_html  'chat_area', :partial = 'chat_area', :object
= [...@chats, @user] if @js_update
  end

in partial chat_area

% if !...@chats.blank?  !show_div(@chats).blank?%
% show_div_id=show_div(@chats) %
  % for chat in @chats %
  div class=popup id=chat_area_%= chat.id %
style=display:%= (chat.id == show_div_id)? 'block' : 'none' %;

% form_remote_for(:chat, :url = {:controller='chats',
:action='create', :id=1}, :html={:name = form_#{chat.id}},
:complete=resetContent('#{chat.id}');) do |f| %
div style=display:none;
%= f.hidden_field :sessionNo, :value=chat.sessionNo %
%= f.text_area :chatContent,  :id=
chatContent_field_#{chat.id}, :cols=100, :rows=6,
:onKeyPress=return submitenter(this,event); %
  /div
input type=image src=images/chat/send-hover.png
value=Send onclick=return submit_button('%= chat.id %')/
% end %
  /div

/div
  % end %

% else %
  div class=popup id=chat_area_none style=display:'block';
  input type=image disabled =disabled
src=images/chat/send.png style=cursor:default; value=Send /
  /div
% end %



Any help is appreciated.


Regards,

Salil Gaikwad
-- 
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.



Re: [Rails] RJS error: TypeError: element is null

2010-03-18 Thread Colin Law
On 18 March 2010 15:33, Salil Gaikwad li...@ruby-forum.com wrote:
 Hi All,

 I got RJS error: TypeError: element is null while using ajax.

 I used  in view

 %= periodically_call_remote(:url={:action='get_user_list', :id='1'},
 :frequency = '5') %

 in controller

      render :update do |page|
        page.replace_html  'chat_area', :partial = 'chat_area', :object
 = [...@chats, @user]     if @js_update
      end

I believe this is expecting to find a div with id chat_area to
replace.  I do not see this div in the code below, though I may be
just not be seeing it.

Colin


 in partial chat_area

 % if !...@chats.blank?  !show_div(@chats).blank?%
    % show_div_id=show_div(@chats) %
  % for chat in @chats %
      div class=popup id=chat_area_%= chat.id %
 style=display:%= (chat.id == show_div_id)? 'block' : 'none' %;

        % form_remote_for(:chat, :url = {:controller='chats',
 :action='create', :id=1}, :html={:name = form_#{chat.id}},
 :complete=resetContent('#{chat.id}');) do |f| %
        div style=display:none;
            %= f.hidden_field :sessionNo, :value=chat.sessionNo %
            %= f.text_area :chatContent,  :id=
 chatContent_field_#{chat.id}, :cols=100, :rows=6,
 :onKeyPress=return submitenter(this,event); %
          /div
            input type=image src=images/chat/send-hover.png
 value=Send onclick=return submit_button('%= chat.id %')/
        % end %
      /div

    /div
  % end %

 % else %
      div class=popup id=chat_area_none style=display:'block';
          input type=image disabled =disabled
 src=images/chat/send.png style=cursor:default; value=Send /
      /div
 % end %



 Any help is appreciated.


 Regards,

 Salil Gaikwad
 --
 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.



-- 
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+prawnto: setting :type to :prawn in a #render_to_string call not working

2010-03-18 Thread Kendall Gifford

On Mar 18, 3:04 am, Michael Pavling pavl...@gmail.com wrote:

 In the end, I wrote some wholly ugly code to get around 
 it:http://www.workingwithrails.com/forums/4-ask-a-rails-expert/topics/80...http://groups.google.com/group/prawn-ruby/browse_thread/thread/185977...

 ... my solution was certainly frowned on by the Prawn core; and
 they're correct. It does seem thatPrawntocauses more problems than
 it solves by trying to be nice. If you follow the Prawn guides for
 integrating with Rails, the process is a lot more re-useable.

 But if you're in my position, and are stuck with loads ofPrawnto
 views you can't get rid of overnight, then the solution I've posted
 will at least let you take their output and put it to different use.

Thanks for the reply. I ended up not needing to do what you did since
I'm not needing to call #render_to_string from a model. However, the
discussions and stuff you mentioned and included in your links gave me
the answer that now works for my case. I was calling #render_to_string
as follows:

document = render_to_string :action = print, :layout = false

This didn't work because the print action had other, non prawnto
templates in its template directory, specifically an RJS template.
Since the action that contained the above line of code was always
being called via AJAX and request.rjs? was always true, my request to
render print as a string would always render my print.rjs template.

Reading your posted threads, I got the idea to try:

document = render_to_string :template = worksheets/
print.pdf.prawn, :layout = false

This works perfectly for me and my simple case.

So, once again, thank!

-- 
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] Problem about each in rails

2010-03-18 Thread Grick Zh
CODE1:

% @posts.each do |p|%
  %=h p.name %
% end %

this will show the name string like Tom in the web page.

CODE2:

%=h @posts.each {|p| p.name} %

why this code return serial strings like #Post:0x3a893e8 ?
-- 
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.



Re: [Rails] Problem about each in rails

2010-03-18 Thread Michael Pavling
On 18 March 2010 16:33, Grick Zh li...@ruby-forum.com wrote:
 %=h @posts.each {|p| p.name} %

 why this code return serial strings like #Post:0x3a893e8 ?

Because you're outputting the return value of the whole loop, not the
output of each block.
If you run that command in your console, you will see it return an
array of Posts; and that's what you're trying to render.

-- 
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: Re: ERROR NoMethodError: private method `gsub!' called

2010-03-18 Thread Chris Mentch
As much of the trace as I can get from my Windows command prompt.  It 
doesn't log this to log/development.log.  You'll see GET calls and then 
the 500 error followed by the private method `gsub!' error message 
repeatedly.  Seems to affect all of the static files---stylesheets, 
javascripts, images.  Sometimes it pulls images from my cache and if I 
refresh the page the image is missing again...



C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in 
`require
'
script/server:3
127.0.0.1 - - [18/Mar/2010:12:15:05 Eastern Daylight Time] GET 
/javascripts/app
lication.js?1263890390 HTTP/1.1 500 338
Referer - /javascripts/application.js?1263890390
127.0.0.1 - - [18/Mar/2010:12:15:05 Eastern Daylight Time] GET 
/javascripts/jqu
ery/jquery.js?1243816946 HTTP/1.1 500 338
Referer - /javascripts/jquery/jquery.js?1243816946
[2010-03-18 12:15:05] ERROR NoMethodError: private method `gsub!' called 
for #C
lass:0x483f450
C:/ruby/lib/ruby/1.8/webrick/htmlutils.rb:16:in `escape'
C:/ruby/lib/ruby/1.8/webrick/httpresponse.rb:232:in `set_error'
C:/ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/webrick_server.rb:94:in 
`
handle_file'
C:/ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/webrick_server.rb:73:in 
`
service'
C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
C:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
C:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
C:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
C:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
C:/ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/webrick_server.rb:60:in 
`
dispatch'
C:/ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/servers/webrick.
rb:66
C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in 
`gem_ori
ginal_require'
C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in 
`require
'
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/de
pendencies.rb:153:in `require'
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/de
pendencies.rb:521:in `new_constants_in'
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/de
pendencies.rb:153:in `require'
C:/ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/server.rb:49
C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in 
`gem_ori
ginal_require'
C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in 
`require
'
script/server:3
[2010-03-18 12:15:05] ERROR NoMethodError: private method `gsub!' called 
for #C
lass:0x483e808
C:/ruby/lib/ruby/1.8/webrick/htmlutils.rb:16:in `escape'
C:/ruby/lib/ruby/1.8/webrick/httpresponse.rb:232:in `set_error'
C:/ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/webrick_server.rb:94:in 
`
handle_file'
C:/ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/webrick_server.rb:73:in 
`
service'
C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
C:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
C:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
C:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
C:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
C:/ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/webrick_server.rb:60:in 
`
dispatch'
C:/ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/servers/webrick.
rb:66
C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in 
`gem_ori
ginal_require'
C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in 
`require
'
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/de
pendencies.rb:153:in `require'
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/de
pendencies.rb:521:in `new_constants_in'
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/de
pendencies.rb:153:in `require'
C:/ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/server.rb:49
C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in 
`gem_ori
ginal_require'
C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in 
`require
'
script/server:3
[2010-03-18 12:15:05] ERROR 

[Rails] Re: Re: ERROR NoMethodError: private method `gsub!' called

2010-03-18 Thread Chris Mentch
Colin Law wrote:
 
 You can tell whether it changed anything by checking your current
 version against the version in your version control repository.  If
 you are not using one (git for example) start by setting one up.  When
 messing about upgrading rails and so on you need to be able to track
 what you have done, revert experimental changes, and so on.  A day or
 two spent learning git will be recovered very quickly.
 
 Colin


I use subversion.  Not much changed after executing rake rails:update 
on my current project. I think it mainly changed the boot.rb file.

What is odd is that I even created a new rails app from scratch and it 
is also having the same problem serving up anything from the public 
folder---stylesheets, javascripts, images, etc...  If I start webrick on 
this new app, it appears that the new rails app page loads with the 
images, but if I refresh, it immediately gives me the 500 errors on the 
static content.

I think I've worked through most of the other problems related to all 
the various plugins I'm using, but this issue still is puzzling why even 
a new rails app has the same problem.

Chris

-- 
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.



Re: [Rails] Re: Re: ERROR NoMethodError: private method `gsub!' called

2010-03-18 Thread Colin Law
On 18 March 2010 17:03, Chris Mentch li...@ruby-forum.com wrote:
...
 What is odd is that I even created a new rails app from scratch and it
 is also having the same problem serving up anything from the public
 folder---stylesheets, javascripts, images, etc...  If I start webrick on
 this new app, it appears that the new rails app page loads with the
 images, but if I refresh, it immediately gives me the 500 errors on the
 static content.

Out of interest have you tried mongrel?
script/server mongrel

Otherwise I am out of my depth I am afraid.

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 at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Memcached using Unix Domain Sockets?

2010-03-18 Thread Jeffrey L. Taylor
Anyone tried using memcached w/ Unix sockets?  Is it faster (for a one host
site) than using the network interface?

TIA,
  Jeffrey

-- 
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: Re: Re: ERROR NoMethodError: private method `gsub!' called

2010-03-18 Thread Chris Mentch
 
 Out of interest have you tried mongrel?
 script/server mongrel
 
 Otherwise I am out of my depth I am afraid.
 
 Colin

Well, I executed gem install mongrel, then ruby script/server 
webrick and everything is loading!!  What a bad problem with webrick. 
My staging server is mongrel, but my production is phusion passenger 
(which is a breeze to setup).  I hope Passenger will be kind when I make 
the next release to production!

I think it even cleared up an annoying stack level too deep error I 
was getting with webrick and not caching classes in development. 
Mongrel isn't complaining.

Thanks for your help!

Chris
-- 
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.



Re: [Rails] Re: Re: Re: ERROR NoMethodError: private method `gsub!' called

2010-03-18 Thread Colin Law
On 18 March 2010 17:36, Chris Mentch li...@ruby-forum.com wrote:

 Out of interest have you tried mongrel?
 script/server mongrel

 Otherwise I am out of my depth I am afraid.

 Colin

 Well, I executed gem install mongrel, then ruby script/server
 webrick and everything is loading!!

I presume you mean ruby script/server mongrel

Colin

 What a bad problem with webrick.
 My staging server is mongrel, but my production is phusion passenger
 (which is a breeze to setup).  I hope Passenger will be kind when I make
 the next release to production!

 I think it even cleared up an annoying stack level too deep error I
 was getting with webrick and not caching classes in development.
 Mongrel isn't complaining.

 Thanks for your help!

 Chris
 --
 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.



-- 
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: HABTM Associations In View

2010-03-18 Thread mastermike2580
try this.

%= n.select :purchase_item_id, PurchaseItem.all.collect {|a| [a.name,
a.id] }, @recipe.purchase_item.id %

Havent tested it so it may or may not work.

On Mar 18, 7:44 am, Andy andy.bo...@gmail.com wrote:
 Hello,
 I wish I had the time to figure this out but I'm on a limited timeline
 to convince people to look at RoR instead of Drupal, so I need to get
 something relatively simple working fast. Any help or pointers would
 be appreciated!

 I have two HABTM many models, recipe_item and purchase_item. I need a
 form to designate in my view that any number of purchase_items or
 recipe_items can be a component of a given recipe_item. It looks like
 Ryan Bates' screencast on nested model forms provides a lot of help on
 a similar issue, but I'm having trouble picking apart the logic for my
 issue. Regardless at the moment as a test I'm just trying to get a
 single select on the recipe_item view to submit the purchase_item
 association. When I submit I get this error:

 PurchaseItem(#20112400) expected, got Array(#102050)

 Here is my code:

 Models:

 class PurchaseItem  ActiveRecord::Base
   has_and_belongs_to_many :recipe_items
 end

 class RecipeItem  ActiveRecord::Base
   has_and_belongs_to_many :purchase_items
 end

 Controllers are left completely as generated by 2.3 Rails scaffolding.

 New recipe_item View:

 h1New recipe_item/h1

 % form_for(@recipe_item) do |f| %
   %= f.error_messages %

   p
     %= f.label :name %br /
     %= f.text_field :name %
   /p
         p
                 % f.fields_for :purchase_items do |n| %
                         %= n.label :purchase_item_id %
                         %= n.select :purchase_item_id, 
 PurchaseItem.all.collect {|a|
 [a.name, a.id] }%
                 % end %
         /p
   p
     %= f.submit 'Create' %
   /p
 % end %

 %= link_to 'Back', recipe_items_path %

 I'm aware this can be DRYed up but like I said right now I just need
 to demonstrate something working for my team. Any help would be
 appreciated!

 Thanks,
 Andy

-- 
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: ruby array inside hash is nil.

2010-03-18 Thread mastermike2580
i am getting this same exact error message when i try to do a
User.find_by_username('array'). Im have twitter users signed up on my
site and i am trying to find the the users on my site from a
timeline.

When i try  %= User.find_by_username('status.user.screen_name') % It
returns nil, but if i use %= status.user.screen_name % it returns
all the user screen names so i can not figure out what is going wrong.


On Mar 18, 3:45 am, Michael Pavling pavl...@gmail.com wrote:
 On 18 March 2010 06:18, Me chabg...@gmail.com wrote:

  I assign an array to a hash value.

  h[:ext_array]  it is nil.

 I copied your hash into IRB and it worked fine: h = {:has_key=0, 
 :ext_array=[Text file (.txt)br/, Rich Text Format

 (.rtf)br/, Word Document (.doc, .docx)br/]}
 = {:has_key=0, :ext_array=[Text file (.txt)br/, Rich Text
 Format\n(.rtf)br/, Word Document (.doc, .docx)br/]} h[:ext_array]

 = [Text file (.txt)br/, Rich Text Format\n(.rtf)br/, Word
 Document (.doc, .docx)br/]



 Can you post the code where you're accessing h[:ext_array] and getting
 nil. I think you might be getting nil as the result of an expression
 rather than the value from the hash.

-- 
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: Problem about each in rails

2010-03-18 Thread tomkurt
If you want the names seperated by comma, try this:

%=h @posts.map{|p| p.name}.join(', ') %

On 18 mrt, 17:48, Michael Pavling pavl...@gmail.com wrote:
 On 18 March 2010 16:33, Grick Zh li...@ruby-forum.com wrote:

  %=h @posts.each {|p| p.name} %

  why this code return serial strings like #Post:0x3a893e8 ?

 Because you're outputting the return value of the whole loop, not the
 output of each block.
 If you run that command in your console, you will see it return an
 array of Posts; and that's what you're trying to render.

-- 
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: Re: Re: Re: ERROR NoMethodError: private method `gsub!' called

2010-03-18 Thread Chris Mentch

 Well, I executed gem install mongrel, then ruby script/server
 webrick and everything is loading!!
 
 I presume you mean ruby script/server mongrel
 
 Colin


Yes... Sorry. Webrick still on the mind.

ruby script/server mongrel

Works!

-- 
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: Records created while tests are running are not being saved.

2010-03-18 Thread Frederick Cheung


On Mar 18, 10:13 am, Steven Hilton mshilt...@gmail.com wrote:
 On Thu, Mar 18, 2010 at 6:08 AM, Vikrant Chaudhary nas...@gmail.com wrote:

 Tests are ran inside a transaction and are rolled back after each
 test. In a separate process (i.e. ./script/dbconsole) you will not see
 the data create from a test, even if you pause execution.

you can see the data during the test if you alter the transaction
isolation level to read uncommitted (at least you can with mysql)

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.



Re: [Rails] Re: Routing Error on rails3

2010-03-18 Thread Felipe Rodrigues




Rails 3 doesn't come with a generic rout mapping for controllers.
The generator for models or scaffold will add the models as resources
routes, so it will be RESTfull by default.

It means that in any new rails 3 app, you will have to explicitly
change the routes.rb to add the routes that are not related to a REST
resource.
Isn't it great? I love rails 3.

[]'s

Felipe

Ugis Ozols wrote:

  Hello,

Here's how your routes.rb file should like for that /pages/home route
to work: http://gist.github.com/316367

In rails 3 rule for catching non-rest routes is deprecated so it's
commented out in routes.rb. You can read about it in Rails 3.0 Release
Notes - http://guides.rails.info/3_0_release_notes.html#action-dispatch

On Feb 26, 10:47 pm, John Wu li...@ruby-forum.com wrote:
  
  
Hi All,

I am new to Ruby on Rails and have rails3 installed.

After I type this on the command line

$rails g controller Pages home contact

then, I go tohttp://localhost:3000/pages/home

I got

Routing Error

No route matches "/pages/contact"

How can I fix this problem?

Thanks!
--
Posted viahttp://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] PAM Authentication

2010-03-18 Thread Evaldo Kalbermatter
Hello everyone! I'm trying to use PAM in my application and found the
gem of Authlogic and rpam. I could not install either the lack of
information. Someone has managed to do it? Google's everywhere and found
nothing. If you can help me I will be very grateful. Have a nice day.
-- 
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] differences between relative_url using Rails with Prototype or JQuery

2010-03-18 Thread Erwin
My web app is deployed with Passenger in a sub-uri,  
http://www.mydomain.com/vacademy/
and I am displaying a player in a page
the swf is located in ../public/dist/flowplayer-3.1.5.swf

Using  Prototype library  I wrote a script :
script
$f(player, ./dist/flowplayer-3.1.5.swf, {

and I don't have any problem to get the player installedfrom
http://www.mydomain.com/vacademy/dist/flowplayer-3.1.5.swf

but when using jQuery
script
$(function() {
 ..
$f(player2, ./dist/flowplayer-3.1.5.swf, {
...
the .swf is not found as the relative url is based on the
controller ...   
http://www.mydomain.com/vacademy/mycontroller/dist/flowplayer-3.1.5.swf

is there anyway to bypass this behavior, not using a relative path or
getting the rails public path in js ?

thanks for your help

erwin

-- 
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: render a Google Chart to a file

2010-03-18 Thread Adam Ziemba
 open('http://chart') do |chart|
File.open('chart.png', 'w') {|f| f.write chart.read }
 end

This is wonderful, I knew nothing of open-uri. However, I cannot seem to 
get it pull an image. Using the Google link above, which produces a PNG 
image, I get the error bad URI(is not URI?).

Looking at the API for open-uri, I could not find any information about 
images.

I played around with it, I can beautifully retrieve web pages and save 
them to disk, but what about images?

Thanks for 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: render a Google Chart to a file

2010-03-18 Thread Adam Ziemba
I managed to get what seems to be a PNG file saved using an actual URL 
to the image:

  File.open 'image.png', 'w' do |file|
open('http://link_to_image.png').path { |chunk| file.write chunk }
  end

Notice the .png extension which is not present with the Google charts 
URL.

This did save image.png to the file system, however the image is 
invalid. So this did not work even for a straight link to a PNG image.

I'm not going to have to use ImageMagick am I? Please tell me no...
-- 
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: Ruby 1.9 loading rails is slow

2010-03-18 Thread ChrisT
I'm having similar issues.
I've tried on a Windows box, as well as Ubuntu 9.04 and 9.10 (both of
which were VirtualBox with Windows XP as the host, but I tossed all
the RAM I could at them). All three environments have rails 3 loading
at an unacceptable speed (30-60 seconds before the environment is even
loaded). I'm at my wits end on this - although I did not try anything
other than 1.9.1 for this. I'll go build 1.8.7 from source on one of
the ubuntu images and give it a shot.

On Mar 10, 3:44 pm, Andrius Chamentauskas sinsil...@gmail.com wrote:
 Hello all,

 I've recently started a project and I wanted to give ruby 1.9 + rails
 a chance. Well everything works great, so far haven't encountered any
 gem that didn't work (so anyone out there you should give it a try).
 There's only one minor glitch: on ruby 1.8.7 loading rails environment
 takes 1-2 secs, on 1.9.1 it takes ~10 secs. Maybe anyone had similar
 problem? I'm on ubuntu 9.10 and I compiled ruby from source (as I've
 noticed it works ~20% faster than apt version).

-- 
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 development processes running very slow

2010-03-18 Thread ChrisT

I hope someone figures something out with this - I'm having similar
issues with ruby 1.9.1 and rails 3 on Windows, Ubuntu 9.04 or 9.10.
Nothing I do seems to help with the load time at all (30-60 seconds).

On Mar 7, 1:29 am, Alex a...@liivid.com wrote:
 This is a problem I know other people have been having.  I'm on Rails
 2.3.5 on a dual core 2.1Ghz Macbook Pro 2.1 with 3Gb of ram and 800Mb+
 inactive memory.  Things should be fast.  Sometimes things run slowly,
 but nothing nearly as slowly as rails.  irb starts in milliseconds.
 Even Java maven tasks are pretty fast.  Rails on the other hand takes
 a pitiful 1:30 minutes to start - the server, console, and tests.
 Simple requests often take 5-10 seconds.

 My ruby version:

 ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.7.0]

 I do have 208 gems installed, many of which are in use.  That could be
 the issue, or it could be some specific gem that's causing a problem.

 Either way, I'm presently missing the startup speed of Java, which
 seems rather ironic.

 My last rails project was with earlier versions when I never had a
 problem.

 Are there any known problems with gems or anything else that cause
 this kind of issue?

 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 at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Ruby 1.9 loading rails is slow

2010-03-18 Thread Conrad Taylor
On Wed, Mar 10, 2010 at 2:44 PM, Andrius Chamentauskas
sinsil...@gmail.comwrote:

 Hello all,

 I've recently started a project and I wanted to give ruby 1.9 + rails
 a chance. Well everything works great, so far haven't encountered any
 gem that didn't work (so anyone out there you should give it a try).
 There's only one minor glitch: on ruby 1.8.7 loading rails environment
 takes 1-2 secs, on 1.9.1 it takes ~10 secs. Maybe anyone had similar
 problem? I'm on ubuntu 9.10 and I compiled ruby from source (as I've
 noticed it works ~20% faster than apt version).



What do you mean when you say loading Rails?  Command-line using webrick or
thin?  Rails console?  Passenger?  Also, what version of Rails are you
using?

-Conrad


  --
 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.comrubyonrails-talk%2bunsubscr...@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] Re: Ruby 1.9 loading rails is slow

2010-03-18 Thread Dermot Brennan
Have you tried ruby 1.9.2-dev?

On Mar 10, 9:44 pm, Andrius Chamentauskas sinsil...@gmail.com wrote:
 Hello all,

 I've recently started a project and I wanted to give ruby 1.9 + rails
 a chance. Well everything works great, so far haven't encountered any
 gem that didn't work (so anyone out there you should give it a try).
 There's only one minor glitch: on ruby 1.8.7 loading rails environment
 takes 1-2 secs, on 1.9.1 it takes ~10 secs. Maybe anyone had similar
 problem? I'm on ubuntu 9.10 and I compiled ruby from source (as I've
 noticed it works ~20% faster than apt version).

-- 
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 development processes running very slow

2010-03-18 Thread Aldric Giacomoni
Alex wrote:
 This is a problem I know other people have been having.  I'm on Rails
 2.3.5 on a dual core 2.1Ghz Macbook Pro 2.1 with 3Gb of ram and 800Mb+
 inactive memory.  Things should be fast.  Sometimes things run slowly,
 but nothing nearly as slowly as rails.  irb starts in milliseconds.
 Even Java maven tasks are pretty fast.  Rails on the other hand takes
 a pitiful 1:30 minutes to start - the server, console, and tests.
 Simple requests often take 5-10 seconds.
 
 My ruby version:
 
 ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.7.0]
 
 I do have 208 gems installed, many of which are in use.  That could be
 the issue, or it could be some specific gem that's causing a problem.
 
Alright.. Are you starting in development mode or in production mode?
Can we see your environment.rb (or the part that relates to gems anyway) 
?
How big is your database?
Are you setting up activemailing ?
-- 
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] Modifying a form field and submitting the form using java script

2010-03-18 Thread Mohammed Alenazi
Hi

I want to modifying a form field and submitting the form using java
script. I know I can do this use basic HTML form code but I want to do
it using the rails way.

-- 
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] Send Java script variable to a controller

2010-03-18 Thread Mohammed Alenazi
I am trying to build an application that has google maps. Inside the
script there are two java script variables. I want to send those two
variables using a java function. What is the best why to do that.
Could someone give me a simple example on that.

-- 
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: ruby array inside hash is nil.

2010-03-18 Thread Chris Habgood
Take out the single quotes.

On Thu, Mar 18, 2010 at 11:47 AM, mastermike2580 mastermik...@gmail.comwrote:

 i am getting this same exact error message when i try to do a
 User.find_by_username('array'). Im have twitter users signed up on my
 site and i am trying to find the the users on my site from a
 timeline.

 When i try  %= User.find_by_username('status.user.screen_name') % It
 returns nil, but if i use %= status.user.screen_name % it returns
 all the user screen names so i can not figure out what is going wrong.


 On Mar 18, 3:45 am, Michael Pavling pavl...@gmail.com wrote:
  On 18 March 2010 06:18, Me chabg...@gmail.com wrote:
 
   I assign an array to a hash value.
 
   h[:ext_array]  it is nil.
 
  I copied your hash into IRB and it worked fine: h = {:has_key=0,
 :ext_array=[Text file (.txt)br/, Rich Text Format
 
  (.rtf)br/, Word Document (.doc, .docx)br/]}
  = {:has_key=0, :ext_array=[Text file (.txt)br/, Rich Text
  Format\n(.rtf)br/, Word Document (.doc, .docx)br/]}
 h[:ext_array]
 
  = [Text file (.txt)br/, Rich Text Format\n(.rtf)br/, Word
  Document (.doc, .docx)br/]
 
 
 
  Can you post the code where you're accessing h[:ext_array] and getting
  nil. I think you might be getting nil as the result of an expression
  rather than the value from the hash.

 --
 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.comrubyonrails-talk%2bunsubscr...@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] Facebook style photo uploader

2010-03-18 Thread Ruby on Rails: Talk
Hi

Does anyone know of a plugin or something similar which would add the
Facebook style photo uploader (or something which will provide the
same function)?

Thanks in advance.

Darren

-- 
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] not null error from PG on build_other call

2010-03-18 Thread byrnejb
I have this code in a stand alone script that uses nokogiri with
activerecord to parse an xml file and initialise a database.

  begin
  this_client = correspondent_f.build_client
  rescue = e
puts(Rescued error in build.)
puts(e.backtrace)
puts( )
puts(correspondent_f.inspect.to_yaml)
raise e
  end

Which, for a certain input record generates this error:

Rescued error in build.
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
connection_adapters/abstract_adapter.rb:219:in `log'
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
connection_adapters/postgresql_adapter.rb:550:in `execute'
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
connection_adapters/abstract/database_statements.rb:265:in
`update_sql'
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
connection_adapters/postgresql_adapter.rb:561:in `update_sql'
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
connection_adapters/abstract/database_statements.rb:49:in
`update_without_query_dirty'
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
connection_adapters/abstract/query_cache.rb:18:in `update'
.  .  .
--- #Correspondent id: 1, correspondent_common_name: \tnt skypak
international exp.\, correspondent_legal_name: \TNT SKYPAK
INTERNATIONAL EXP.\, correspondent_legal_form: \UNKN\,
correspondent_legal_name_key: \tntskypakinternationalexp\,
correspondent_status: \HOLD\, changed_at: \2010-03-18 19:49:49\,
changed_by: \hp3000_client_import\, created_at: \2010-03-18
19:49:49\, created_by: \hp3000_client_import\, lock_version: 0
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record

/connection_adapters/abstract_adapter.rb:219:in `log': PGError:
ERROR:  null value in column correspondent_id violates not-null
constraint (ActiveRecord::StatementInvalid)
:   UPDATE clients
  SET changed_at = '2010-03-18 20:07:44',
correspondent_id = NULL, lock_version = 1
  WHERE id = 1
  AND lock_version = 0
from /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.5/lib/
active_record/connection_adapters/postgresql_adapter.rb:550:in
`execute'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.5/lib/
active_record/connection_adapters/abstract/database_statements.rb:
265:in `update_sql'
.  .  .

Now, I know that the record triggering the exception is a duplicate of
one already previously loaded into the clients table.  This in fact
should trigger a validation error in the Correspondent class. But I do
not see that validation error anywhere and I cannot understand why the
correspondent_id value is null in the second case.

The Client class has this:

  belongs_to :correspondent
  validates_associated
  validates_presence_of :effective_from
  validate :date_range

The Correspondent class has this:

  has_one  :client

I am sure that this situation has a simple explanation and I hope that
someone can provide it to me.

-- 
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: render a Google Chart to a file

2010-03-18 Thread Colin Law
On 18 March 2010 18:50, Adam Ziemba li...@ruby-forum.com wrote:
 open('http://chart') do |chart|
    File.open('chart.png', 'w') {|f| f.write chart.read }
 end

 This is wonderful, I knew nothing of open-uri. However, I cannot seem to
 get it pull an image. Using the Google link above, which produces a PNG
 image, I get the error bad URI(is not URI?).

I think you have two problems, firstly you need to escape the uri,
this seems to work but there is probably a nicer way of doing it:

open(http://chart.apis.google.com/chart#{CGI.escape('?cht=bvgchbh=achd=s:vttustychs=500x300chxt=x,ychxl=0:|Sun|Mon|Tue|Wed|Thu|Fri|Sat|1:|0|2|4|6|8|10|12')})
do |chart|
  File.open('chart.png', 'w') {|f| f.write chart.read }
end

Unfortunately you do not end up with a png file.  If you open the file
with a text editor you will find it is a web page with loads of
javascript.  Presumably the javascript generates the png.  I think you
need an alternative approach.

Colin


 Looking at the API for open-uri, I could not find any information about
 images.

 I played around with it, I can beautifully retrieve web pages and save
 them to disk, but what about images?

 Thanks for 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.



-- 
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: require behaves differently in Rails vs vanilla Ruby?

2010-03-18 Thread Poco Ritard
Ah.  Thanks, this makes (more) sense now.

On Mar 18, 2:05 am, Frederick Cheung frederick.che...@gmail.com
wrote:

 The easy way here is torequireconfig/environment which loads up
 rails for you. If you just want the const autoloading you can set that
 up to but you'll have to delve into the Rails startup stuff to see how
 it initializes stuff.

-- 
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] Symbol as array index error ?

2010-03-18 Thread Dudebot
Anybody have any idea why this is throwing an error:

@monkey = params[ :lab ][ :existing_lab_data_attributes ]
raise @monkey.to_yaml

--- !map:HashWithIndifferentAccess
133: !map:HashWithIndifferentAccess
  unit_id: 2
  lab_desc_id: 2
  value: 500
145: !map:HashWithIndifferentAccess
  unit_id: 4
  lab_desc_id: 3
  value: 
...

But when I try

@monkey.delete_if{ |x| x[ :value ].blank? }

I get the error:

Symbol as array index

Any ideas what's happening, and how to delete blanks in @monkey?

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-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] Memcached using Unix Domain Sockets?

2010-03-18 Thread Jeffrey L. Taylor
Quoting Jeffrey L. Taylor r...@abluz.dyndns.org:
 Anyone tried using memcached w/ Unix sockets?  Is it faster (for a one host
 site) than using the network interface?
 

Digging into the code makes it clear that memcache-client does not support
Unix domain sockets.  :(

Jeffrey

-- 
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] rake db:migrate - uninitialized constant

2010-03-18 Thread trans
Hi--

I'm trying to do a first migration (2.3.5). I generated a model
Video, but when I try to migrate I get uninitialized constant
Videos. Why is it trying to find a plural class name?

Here's more complete output:

tr...@logisys:models$ rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
An error has occurred, this and all later migrations canceled:

uninitialized constant Videos
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/
dependencies.rb:443:in `load_missing_constant'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/
dependencies.rb:80:in `const_missing'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/
dependencies.rb:92:in `const_missing'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/
inflector.rb:361:in `constantize'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/
inflector.rb:360:in `each'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/
inflector.rb:360:in `constantize'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/
core_ext/string/inflections.rb:162:in `constantize'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
migration.rb:374:in `load_migration'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
migration.rb:369:in `migration'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
migration.rb:365:in `migrate'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
migration.rb:486:in `migrate'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
migration.rb:560:in `call'
...

-- 
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: Symbol as array index error ?

2010-03-18 Thread Frederick Cheung


On Mar 18, 9:40 pm, Dudebot craign...@gmail.com wrote:
 Anybody have any idea why this is throwing an error:

 @monkey = params[ :lab ][ :existing_lab_data_attributes ]
 raise @monkey.to_yaml

 --- !map:HashWithIndifferentAccess
 133: !map:HashWithIndifferentAccess
   unit_id: 2
   lab_desc_id: 2
   value: 500
 145: !map:HashWithIndifferentAccess
   unit_id: 4
   lab_desc_id: 3
   value: 
 ...

 But when I try

 @monkey.delete_if{ |x| x[ :value ].blank? }


Because @monkey is a hash what gets yielded to you is an array, the
first element is the key (ie '133' or '145') and the second is the
value, whereas your code seems to assume that x is a hash.

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] TEKsystems - Ruby on Rails Job Opportunities

2010-03-18 Thread Sidney
Hi Everyone,

I am an IT recruiter with TEKsystems, and I am working with a local
client here in New Orleans. This client has a need for multiple Ruby
on Rails developers. The position allows for a lot of flexibility. If
you are an entry level Ruby developer, they are willing to bring you
on board and help teach you Ruby. If you are more experienced with it,
they would also like to bring you on board. I have short contracts
available and I also have contract-to-permanent positions as well.

If you would like to learn more about it or if you know anyone that
might be interested, I would be glad to speak with you. Please give me
a call at (504) 218-2645 or email me at sbenn...@teksystems.com.
Thanks!



SIDNEY BENNETT TECHNICAL RECRUITER
3501 N. CAUSEWAY BLVD., SUITE 601

METAIRIE, LA 70002
T 504.218.2645
F 504.218.2690

sbenn...@teksystems.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.



  1   2   >