Ruby on Rails Saturday, March 31, 2012

Try 

  
  rake routes

 - and you will see, there really isn't defined a student_acounts_path

Try:
resources :students do
  resources :accounts
end


or alternatively in your show (if you want to add a show, edit or update-action in your accounts_controller without an :id param)

form_for [@student, @student.build_account], :url => student_account_path(@student)


best,
B. Pieck


On Sun, Apr 1, 2012 at 3:04 AM, ayesha fernando <lists@ruby-forum.com> wrote:
I keep getting the following error:
NoMethodError in Students#show
undefined method `student_accounts_path' for
#<#Class:0x007ffe2bf6d688>:0x007ffe2c5e5628>

I am trying to implement a has_one model. I followed the rails guide
that used the :post has_many :comments example and tweaked it a bit.

my routes.rb file looks like this:
resources :students do
   resource :account
end

My Students.controller, Account.controller files are attached.
Along with the /app/views/students/show.html.erb file

I have no idea what I'm doing wrong.
Can anyone please help me?

Attachments:
http://www.ruby-forum.com/attachment/7210/students_controller.rb
http://www.ruby-forum.com/attachment/7211/accounts_controller.rb
http://www.ruby-forum.com/attachment/7212/show.html.erb


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

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


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

Ruby on Rails

I keep getting the following error:
NoMethodError in Students#show
undefined method `student_accounts_path' for
#<#Class:0x007ffe2bf6d688>:0x007ffe2c5e5628>

I am trying to implement a has_one model. I followed the rails guide
that used the :post has_many :comments example and tweaked it a bit.

my routes.rb file looks like this:
resources :students do
resource :account
end

My Students.controller, Account.controller files are attached.
Along with the /app/views/students/show.html.erb file

I have no idea what I'm doing wrong.
Can anyone please help me?

Attachments:
http://www.ruby-forum.com/attachment/7210/students_controller.rb
http://www.ruby-forum.com/attachment/7211/accounts_controller.rb
http://www.ruby-forum.com/attachment/7212/show.html.erb


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

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

Ruby on Rails

On Sat, Mar 31, 2012 at 5:25 PM, Alex Mercer <alexey.bobyrev@gmail.com> wrote:
> gem update --system

Actually, that might not work on a Debian based distro if rubygems has
been installed via apt packages.
That's why I asked how Ruby was installed.

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

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

Ruby on Rails

On Sat, Mar 31, 2012 at 10:28 PM, jenna_s <jenna.simmer@gmail.com> wrote:
> Hi,
>
> I'm having trouble with a simple users-messages setup, where users can
> send messages to other users. Here's my class definition:
>
> class Message < ActiveRecord::Base
>  belongs_to :from_user, :class_name => 'User'
>  belongs_to :to_user, :class_name => 'User'
> end
>
> class User < ActiveRecord::Base
>  def messages(with_user_id)
>    Message.where("from_user_id = :id AND to_user_id = :with_user_id
> OR to_user_id = :id AND from_user_id = :with_user_id",
>      { :id => id, :with_user_id => with_user_id })
>      .includes(:from_user, :to_user)
>      .order("created_at DESC")
>  end
> end
>
> When I do some_user.messages(another_user.id), I want to retrieve the
> conversation that some_user has with another_user. I do get back an
> array of Messages, but it doesn't include the eager loading of
> from_user and to_user.

How many SQL queries do you see in the log for

messages = some_user.messages(another_user.id)

(I believe you should see 3 queries if from_user and to_user data
is present).

When asking later on:

messages.first.from_user

is it then launching an SQL for the individual from_user
at that time?

> What am I doing wrong? Am I forced to use
> joins?

It must be possible to get this working with .includes
as you tried.

HTH,

Peter

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

Ruby on Rails

Hi,

I'm having trouble with a simple users-messages setup, where users can
send messages to other users. Here's my class definition:

class Message < ActiveRecord::Base
belongs_to :from_user, :class_name => 'User'
belongs_to :to_user, :class_name => 'User'
end

class User < ActiveRecord::Base
def messages(with_user_id)
Message.where("from_user_id = :id AND to_user_id = :with_user_id
OR to_user_id = :id AND from_user_id = :with_user_id",
{ :id => id, :with_user_id => with_user_id })
.includes(:from_user, :to_user)
.order("created_at DESC")
end
end

When I do some_user.messages(another_user.id), I want to retrieve the
conversation that some_user has with another_user. I do get back an
array of Messages, but it doesn't include the eager loading of
from_user and to_user. What am I doing wrong? Am I forced to use
joins?

Thanks,
J

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

Ruby on Rails

gem update --system

On Saturday, March 31, 2012 6:00:19 AM UTC+3, Ruby-Forum.com User wrote:

I'm trying to install Ruby on Rails on Ubuntu 11.10, but receiving this
error:

    $ sudo gem install rails
    ERROR:  While executing gem ... (Gem::DependencyError)
        Unable to resolve dependencies: rails requires activesupport (=
3.2.3), actionpack (= 3.2.3), activerecord (= 3.2.3), activeresource (=
3.2.3), actionmailer (= 3.2.3), railties (= 3.2.3)


How can I fix this?

Note: Git (1.7.5.4 ) and Ruby (1.9.2p290) are installed properly.

--
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 view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/10czl1b24KkJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Ruby on Rails

hi im new ruby on rails development currently im working with a
reservation system to start learning but im currently having a problem
with controllers and view

first i listed all the menu that the guest added inside the package that
he also added i listed them with this

_menuadded.html.erb

<h1>menu you added</h1>
<% @reservation_package.package_line_items.each do |menu|%>
<p><%= link_to menu.menu.name,
menu_reservation_reservation_package_reservation_package_pages_path(@reservation,@reservation_package,menu)
%></p>
<p><%= link_to "delete item"
,reservation_package_package_line_item_path(@reservation_package,menu),
:method => :delete%></p>
<%end%>

then i try to route to the next static page with this ` <p><%=
link_to menu.menu.name,
menu_reservation_reservation_package_reservation_package_pages_path(@reservation,@reservation_package,menu)
%></p>`

and the it produce this URL
`http://localhost:3000/reservations/10/reservation_packages/39/reservation_package_pages/menu.29`

im just wondering if how can i catch the menu that he opened i mean how
to catch this
**localhost:3000/reservations/10/reservation_packages/39/reservation_package_pages/`menu.29`**

in my menu semi static page controller where this route to,i tried this

@reservation_package =
ReservationPackage.find(params[:reservation_package_id])
@menu = Menu.find(params[:id])

but didn't work at all im just wondering if im doing it right or if im
wrong can you give me a advice how to implement this kind of module?
thanks more power


**ROUTES:**

resources :services

resources :reservations do

resources :pages do
collection do
get :functionroomlist
get :packagelist
get :package
# get :menu
end
end
resources :reservation_packages do
resources :reservation_package_pages do
collection do
get :menulist
get :menu
end
end
resources :package_line_items
end
resources :reservation_function_rooms
end

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

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

Ruby on Rails

"Zoltán Iklódi" <ziklodi@gmail.com> wrote in post #1054400:
> Hello,
>
> I want to add a Partner property to more than one type of models (ie.
> SalesOrder and PurchaseOrder).
> Is this the proper way of defining associatons or there's a simpler
> way?

What you need here is a polymorphic association. See:

http://guides.rubyonrails.org/association_basics.html#polymorphic-associations

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

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

Ruby on Rails

On Sat, Mar 31, 2012 at 7:59 PM, Linus Pettersson
<linus.pettersson@gmail.com> wrote:
> Hi!
>
> I'm creating a simple signup form where people can sign up for a camp. They
> should be able to add a contact person and also sign up other people (such
> as family members).
>
> Two models:
> Application
>   has_many :participants
>   accepts_nested_attributes_for :participants
>
> Participant
>   belongs_to :application
>
> I have some trouble with the contact person, which is also a participant. I
> guess I should add something like this:
>
> Application
>   has_many :participants
>   belongs_to :contact_person, :class_name => "Participant", :foreign_key =>
> "contact_person_id"
>   accepts_nested_attributes_for :participants, :contact_person
>
> Ok, so then I try to set up my nested form. In my ApplicationsController#new
> method I do this:
>
> def new
>     @application = Application.new
>     2.times { @application.participants.build }
>     1.times { @application.contact_person.build }
> end
>
> But that gives me an error: "undefined method `build' for nil:NilClass".The
> error comes from: "@application.contact_person.build", so contact_person is
> nil.

The correct wording is (somewhat confusingly)

@application.build_contact_person

Check these tables for the exact names of the singular and plural associations:

http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html

HTH,

Peter

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

Ruby on Rails

Hi!


I'm creating a simple signup form where people can sign up for a camp. They should be able to add a contact person and also sign up other people (such as family members).

Two models:
Application
  has_many :participants
  accepts_nested_attributes_for :participants

Participant
  belongs_to :application

I have some trouble with the contact person, which is also a participant. I guess I should add something like this:

Application
  has_many :participants
  belongs_to :contact_person, :class_name => "Participant", :foreign_key => "contact_person_id"
  accepts_nested_attributes_for :participants, :contact_person
  
Ok, so then I try to set up my nested form. In my ApplicationsController#new method I do this:

def new
    @application = Application.new
    2.times { @application.participants.build }
    1.times { @application.contact_person.build }
end

But that gives me an error: "undefined method `build' for nil:NilClass". The error comes from: "@application.contact_person.build", so contact_person is nil.


So, any ideas what I have done wrong? It was a while ago I fiddled with nested forms like this...

Thanks!

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

Ruby on Rails

Hi,

I'm trying to execute some javascript in the browser after completing
my create action in the controller. Here's how I'm doing it:

In my controller:
def create
# exectue some code
js = render_to_string(:layout => false, :template =>
"planned_meals/meal.js.coffee.erb")
render :js => js
end


Two questions:
1) Am I going about it the right way? Should I be rendering the js
differently?

2) WIth this implementation, everything works great, but I'm getting
the following deprecation warning:
"DEPRECATION WARNING: Passing a template handler in the template name
is deprecated. You can simply remove the handler name or pass
render :handlers => [:erb] instead."
However, if I change the render_to_string call to this:

render_to_string(:layout => false, :template => "planned_meals/
meal", :format => [:js], :handlers => [:coffee, :erb])

Then I get a missing template error. I'm not sure how to get around
the deprecation warning.

Thanks for all your help,
Nick

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

Ruby on Rails

My apologies Walter, et al.

I haven't had access to my computers within the last 24 hrs. I shall
look into your recommendations tonight.

As always, thank you for your assistance and prompt replies.

~Kal


On Mar 30, 9:26 am, Walter Lee Davis <wa...@wdstudio.com> wrote:
> On Mar 30, 2012, at 12:34 AM, Kal wrote:
>
> > Hi Walter,
>
> > I did as instructed but now getting a "rake aborted! stack level too
> > deep (in /home/rubys/work/depot/app/assets/stylesheets/
> > scaffolds.css.scss)" error.
>
> > I tried to modify "config.assets.compile = true: (from false) within
> > config/environments/production.rb but still no good :(
>
> What version of rake? What version of bundler? Have you run bundle install or bundle update on your server? I'm guessing in the dark here, but it sounds like you may not have everything the same on your server as your dev box, version-wise. If you were able to use the site locally, it should work on the server. Try running the site in production on your development machine, using
>
> rake db:migrate RAILS_ENV=production
> rake assets:precompile
> rails server RAILS_ENV=production
>
> to duplicate the experience locally. See if it's specific to this server.
>
> Also, try prefixing your assets:precompile step on the server with bundle exec so you're sure you're getting the actual versions of everything when you do that.
>
> Walter
>
>
>
>
>
>
>
>
>
> > Thanks Again,
>
> > -Kin
>
> > ---------------------------------------------------------------------------------------------------------------------
>
> > # rake assets:precompile --trace
>
> > ** Invoke assets:precompile (first_time)
> > ** Execute assets:precompile
> > /usr/local/bin/ruby /usr/local/bin/rake assets:precompile:all
> > RAILS_ENV=production RAILS_GROUPS=assets --trace
> > ** Invoke assets:precompile:all (first_time)
> > ** Execute assets:precompile:all
> > ** Invoke assets:precompile:primary (first_time)
> > ** Invoke assets:environment (first_time)
> > ** Execute assets:environment
> > ** Invoke environment (first_time)
> > ** Execute environment
> > ** Invoke tmp:cache:clear (first_time)
> > ** Execute tmp:cache:clear
> > ** Execute assets:precompile:primary
> > rake aborted!
> > stack level too deep
> >  (in /home/rubys/work/depot/app/assets/stylesheets/
> > scaffolds.css.scss)
> > /usr/local/lib/ruby/1.9.1/rake/task.rb:162
> > Tasks: TOP => assets:precompile:primary
> > rake aborted!
> > Command failed with status (1): [/usr/local/bin/ruby /usr/local/bin/
> > rake as...]
> > /usr/local/lib/ruby/1.9.1/rake/file_utils.rb:53:in `block in
> > create_shell_runner'
> > /usr/local/lib/ruby/1.9.1/rake/file_utils.rb:45:in `call'
> > /usr/local/lib/ruby/1.9.1/rake/file_utils.rb:45:in `sh'
> > /usr/local/lib/ruby/1.9.1/rake/file_utils_ext.rb:39:in `sh'
> > /usr/local/lib/ruby/1.9.1/rake/file_utils.rb:80:in `ruby'
> > /usr/local/lib/ruby/1.9.1/rake/file_utils_ext.rb:39:in `ruby'
> > /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.1.3/lib/sprockets/
> > assets.rake:9:in `ruby_rake_task'
> > /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.1.3/lib/sprockets/
> > assets.rake:17:in `invoke_or_reboot_rake_task'
> > /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.1.3/lib/sprockets/
> > assets.rake:25:in `block (2 levels) in <top (required)>'
> > /usr/local/lib/ruby/1.9.1/rake/task.rb:205:in `call'
> > /usr/local/lib/ruby/1.9.1/rake/task.rb:205:in `block in execute'
> > /usr/local/lib/ruby/1.9.1/rake/task.rb:200:in `each'
> > /usr/local/lib/ruby/1.9.1/rake/task.rb:200:in `execute'
> > /usr/local/lib/ruby/1.9.1/rake/task.rb:158:in `block in
> > invoke_with_call_chain'
> > /usr/local/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
> > /usr/local/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
> > /usr/local/lib/ruby/1.9.1/rake/task.rb:144:in `invoke'
> > /usr/local/lib/ruby/1.9.1/rake/application.rb:116:in `invoke_task'
> > /usr/local/lib/ruby/1.9.1/rake/application.rb:94:in `block (2 levels)
> > in top_level'
> > /usr/local/lib/ruby/1.9.1/rake/application.rb:94:in `each'
> > /usr/local/lib/ruby/1.9.1/rake/application.rb:94:in `block in
> > top_level'
> > /usr/local/lib/ruby/1.9.1/rake/application.rb:133:in
> > `standard_exception_handling'
> > /usr/local/lib/ruby/1.9.1/rake/application.rb:88:in `top_level'
> > /usr/local/lib/ruby/1.9.1/rake/application.rb:66:in `block in run'
> > /usr/local/lib/ruby/1.9.1/rake/application.rb:133:in
> > `standard_exception_handling'
> > /usr/local/lib/ruby/1.9.1/rake/application.rb:63:in `run'
> > /usr/local/bin/rake:32:in `<main>'
> > Tasks: TOP => assets:precompile
>
> > ---------------------------------------------------------------------------------------------------------------------
>
> > On Mar 29, 11:37 pm, Walter Lee Davis <wa...@wdstudio.com> wrote:
> >> On Mar 29, 2012, at 10:51 PM, Kal wrote:
>
> >>> (Re-posting)
>
> >>> Thanks Walter,
>
> >>> I think you are correct.  I had neglected to set up a production
> >>> version of the database.
>
> >>> I just ran "rake db:migrate RAILS_ENV=production".  However, I now get
> >>> a "500 Internal Server Error".
>
> >>> Anyway, here is the error from production.log.  Any ideas?
>
> >> Sure. rake assets:precompile and you should be good to go.
>
> >> Walter
>
> >>> Thanks,
>
> >>> Kal
>
> >>> -----------------------------------------------------------------------------------------------------------------------------
>
> >>>  Processing by StoreController#index as HTML
> >>> Rendered store/index.html.erb within layouts/application (17.9ms)
> >>> Completed 500 Internal Server Error in 38ms
>
> >>> ActionView::Template::Error (all.css isn't precompiled):
> >>>    2: <html>
> >>>    3: <head>
> >>>    4:   <title>Depot</title>
> >>>    5:   <%= stylesheet_link_tag :all %>
> >>>    6:   <%= javascript_include_tag :defaults %>
> >>>    7:   <%= csrf_meta_tag %>
> >>>    8: </head>
> >>>  app/views/layouts/application.html.erb:5:in
> >>> `_app_views_layouts_application_html_erb__750878_73537400'
>
> >>> ---------------------------------------------------------------------------------------------------------------------------
>
> >>> On Mar 29, 4:12 pm, Walter Lee Davis <wa...@wdstudio.com> wrote:
> >>>> On Mar 28, 2012, at 8:56 PM, Kal wrote:
>
> >>>>> Hi All,
>
> >>>>> Can someone please help?  I've been banging my head against for wall
> >>>>> for 2 months; all of which has been spent trying to set up ROR.  So I
> >>>>> actually haven't written 1 line of code :(  Any help would be greatly
> >>>>> appreciated :)
>
> >>>>> I'm following the 4th edition of "Agile Web Development with Rails".
> >>>>> So, I'm able to deploy the site via WEBrick.  However, when I go to my
> >>>>> URL (without using port 3000), I get the error message below.  What am
> >>>>> I missing?
> >>>>> ---------------------------------------------------------------------------------------------------------------
>
> >>>>> Ruby (Rack) application could not be started
> >>>>> These are the possible causes:
>
> >>>>> There may be a syntax error in the application's code. Please check
> >>>>> for such errors and fix them.  A required library may not installed.
> >>>>> Please install all libraries that this application requires.  The
> >>>>> application may not be properly configured. Please check whether all
> >>>>> configuration files are written correctly, fix any incorrect
> >>>>> configurations, and restart this application.  A service that the
> >>>>> application relies on (such as the database server or the Ferret
> >>>>> search engine server) may not have been started.  Please start that
> >>>>> service.
>
> >>>>> Further information about the error may have been written to the
> >>>>> application's log file. Please check it in order to analyse the
> >>>>> problem.
>
> >>>>> Error message:
> >>>>>    unable to open database file (SQLite3::CantOpenException)
> >>>>> Exception class:
> >>>>>    PhusionPassenger::UnknownError
> >>>>> Application root:
> >>>>>    /home/rubys/work/depot
> >>>>> Backtrace
>
> >>>>> ---------------------------------------------------------------------------------------------------------------
>
> >>>>> This is the error in /var/log/httpd/error_log
>
> >>>>> *** Exception PhusionPassenger::UnknownError in
> >>>>> PhusionPassenger::Rack::ApplicationSpawner (unable to open database
> >>>>> file (SQLite3::CantOpenException)) (process 3244, thread #<Thread:
> >>>>> 0xa1db870>):
>
> >>>>> ---------------------------------------------------------------------------------------------------------------
>
> >>>>> By the way, I'm running:
>
> >>>>> Ruby 1.9.3p0
> >>>>> Rails 3.1.3
> >>>>> Phusion Passenger version 3.0.11
> >>>>> CentOS release 5.6
> >>>>> Server version: Apache/2.2.3
>
> >>>>> ---------------------------------------------------------------------------------------------------------------
>
> >>>>> This my vhost configuration from httpd.conf
>
> >>>>> <VirtualHost *:80>
> >>>>>   ServerNamewww.mywebpage.com
> >>>>>   DocumentRoot /home/rubys/work/depot/public/
>
> >>>>>   <Directory /home/rubys/work/depot/public>
> >>>>>        Order allow,deny
> >>>>>        Allow from all
> >>>>>   </Directory>
>
> >>>>> </VirtualHost>
>
> >>>> By any chance, have you run rake:db:migrate RAILS_ENV=production yet? If not, then one possible reason why you can't open the database is that it does not exist.
>
> >>>> Walter
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> >>> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> >>> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> >>> For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> > To post to this group, send email to rubyonrails-talk@googlegroups.com.
> > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.

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

Ruby on Rails

Hi all, 


I am a brand new user here so please accept my apologies if this has already been covered. 

I have searched extensively for the problem I'm having but cannot find a solution. Also, I am very new to Ruby on Rails. I played around with RoR back in 2008 but never fully got into it. 

I have installed all the required and not-so-required things needed like rvm, homebrew, xcode (I'm on an iMac Lion OSX).

I'm trying to follow the Rails Cast from Ryan Bates called #332 Refinery CMS Basics located here: http://railscasts.com/episodes/332-refinery-cms-basics

The problem is this:

I installed "imagemagick" as it suggests in the video. However, I keep running into an issue where the "libtiff" dependency won't install on my machine. So I ran "brew doctor" to diagnose and it tells me "You should `brew install` the missing dependencies: brew install libtiff".

So, I did "brew install" and it starts making and configuring the libtiff and make installing but after a few seconds it says "error: OpenGL/gl.h: No such file or directory" as well as "Error: Failed executing: make install (libtiff.rb:18)" 

I know this isn't specifically a Rails issue but since I'm trying to play around RefineryCMS fromt he railscasts video I just wonder if anyone else has had this same issue?  If so, any ideas on how to fix the problem?  I know that this will effect other things as well so not sure what I'm doing wrong.

Any information would be very helpful. Also, keep in mind I'm no expert at the command line.

If you need more information please let me know and I'll do my best. I didn't want to copy/paste everything just yet in case it was a simple answer.

Thanks very much in advance.

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

Ruby on Rails

I tried out some code in my console and I am having difficulty translating it for my view and controller so that it gives me the same result. My console:          @contract = Contract.new(authnum: "900700", st_date:"2012-01-01", end_date: "2012-30-06")          @contract.save          @code = Code.new(code_name: "S-5463", status: "Active",  description: "This and That")          @code.save          @codeline = @code.codelines.build(:units_alloc => "80.00", :contract => @contract)          @codeline.save          @codeline         => #<Codeline id: 91, contract_id: 64, code_id: 54, units_alloc: 80.00>  Using pgadmin3 I check my codelines table and I get the same result namely:          id    contract_id    code_id   units_alloc         91         64            54       80.00  But if I try to run this through my contracts_controller and view I get:          id    contract_id    code_id   units_alloc         1         1           1               ---I think this record comes from the @contract.codes.build         1         1                     80.00 ---I think this record comes from the @contract.codelines.build(:units_alloc => params[:units_alloc],:contract => @contract)   Here are my models:    class Contract < AR::Base     has_many :codelines     has_many :codes, :through => :codelines      accepts_nested_attributes_for :codes      attr_accessible :codes_attributes,:codes,:authnum,:st_date,:end_date   end    class Codeline < AR::Base     belongs_to :contract     belongs_to :code     units_alloc ...... this is the attribute I would like to set   end    class Code < AR::Base     has_many :codelines     has_many :contracts, :through => :codelines   end  The new/create action of my app/controllers/contracts_controller.rb    def new     @contract = Contract.new     @contract.codes.build     @contract.codelines.build(:units_alloc => params[:units_alloc],:contract => @contract)   end    def create      @contract = Contract.new(params[:contract])      if @contract.save        flash[:success] = "New Contract has been saved"        redirect_to @contract      else        @title = "You have some errors"        render 'new'      end    end  the partial for my view in app/views/contracts/_fields.html.haml      = f.fields_for :codes do |ff|       .field          = ff.label :name, "Code Name"          %br/          = ff.text_field :code_name       .field       .       .     = f.fields_for :codelines do |ff|       .field         = ff.label :name, "Units Alloc"         %br/         = ff.text_field :units_alloc

Can you please have a look at this and give me some direction?

Thanks.

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

Ruby on Rails

On 29 March 2012 17:17, bingo bob <lists@ruby-forum.com> wrote:
> Schema attached..
>
> model summaries...
>
> class Name < ActiveRecord::Base
>
>  attr_accessible :given, :gender, :position
>
>  has_many :user_names
>  has_many :users, :through => :user_names
>
>
> class UserNames < ActiveRecord::Base
>  belongs_to :user
>  belongs_to :name
>
>
> class User < ActiveRecord::Base
>  # Include default devise modules. Others available are:
>  # :token_authenticatable, :encryptable, :confirmable, :lockable,
> :timeoutable and :omniauthable
>  devise :database_authenticatable, :registerable,
>         :recoverable, :rememberable, :trackable, :validatable
>
>  has_many :user_names
>  has_many :names, :through => :user_names
> ...
> So with all that in place and data mover run console gives me errors...
>
> ruby-1.9.2-p290 :006 > User.first.names
>  User Load (1.4ms)  SELECT "users".* FROM "users" ORDER BY
> lower(username) ASC LIMIT 1
> NameError: uninitialized constant User::UserName

What is that ORDER BY lower(username) doing? I don't see where that
is coming from in your code.

What happens if you do User.first

Colin

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

Ruby on Rails

Hello,

I want to use HTTP streaming (Rails 3.2.2) to reduce my load time and
have tried it successfully, but it doesn't work with I18n.t – the
strings are not translated. Don't know why, I guess the relevant code
is not loaded at this time. Is there a tutorial / known best way to do
I18n with HTTP streaming?

Greetings

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

Ruby on Rails

Ok this might sound funny but , this problem is usually caused by lack
of javascript libraries in your rails setup so i would recommend you to
do this .

Install this gem and you should be ready to go

gem install therubyracer

If it works or it doesnt work let me know

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

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

Ruby on Rails

Hi

I've tried this on a virgin Rails 3.2.2 app. If you put the translations
for country names in the locale file using the 2 letter ISO code, it
looks something like this:

en:
countries:
DE: "Germany"
NO: "Norway"
US: "USA"

This works fine - but for Norway :-)

I18n.t :'countries.DE' # => "Germany"
I18n.t :'countries.NO' # => "translation missing: en.countries.NO"

Case doesn't matter, the same happens with :'countries.no'.

Any idea what could be the cause for this problem?

Thanks!

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

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

Ruby on Rails Friday, March 30, 2012

On Sat, Mar 31, 2012 at 12:00 AM, Paulo Cassiano <lists@ruby-forum.com> wrote:
> I'm trying to install Ruby on Rails on Ubuntu 11.10, but receiving this
> error:
>
>    $ sudo gem install rails
>    ERROR:  While executing gem ... (Gem::DependencyError)
>        Unable to resolve dependencies: rails requires activesupport (=
> 3.2.3), actionpack (= 3.2.3), activerecord (= 3.2.3), activeresource (=
> 3.2.3), actionmailer (= 3.2.3), railties (= 3.2.3)
>
>
> How can I fix this?
>
> Note: Git (1.7.5.4 ) and Ruby (1.9.2p290) are installed properly.
>
How did you installed Ruby?
Do you have an updated rubygems?

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

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

Ruby on Rails

I'm trying to install Ruby on Rails on Ubuntu 11.10, but receiving this
error:

$ sudo gem install rails
ERROR: While executing gem ... (Gem::DependencyError)
Unable to resolve dependencies: rails requires activesupport (=
3.2.3), actionpack (= 3.2.3), activerecord (= 3.2.3), activeresource (=
3.2.3), actionmailer (= 3.2.3), railties (= 3.2.3)


How can I fix this?

Note: Git (1.7.5.4 ) and Ruby (1.9.2p290) are installed properly.

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

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

Ruby on Rails

Rails 3.2.3 has been released!!!.

### IMPORTANT

This release changes the default value of
*config.active_record.whitelist_attributes* to true. This change only
affects newly generated applications so it should not cause any
backwards compatibility issues for users who are upgrading but it may
affect some tutorials and introductory material. For more information
see the mass assignment section of the [ruby on rails security
guide][1]

Rails 3.2.3 also introduces a new option that allows you to control
the behavior of remote forms when it comes to `authenticity_token`
generation. If you want to fragment cache your forms, authenticity
token will also get cached, which isn't acceptable. However, if you
only use such forms with ajax, you can disable token generation,
because it will be fetched from `meta` tag. Starting with 3.2.3, you
have an option to stop generating `authenticity_token` in remote forms
(ie. `:remote => true` is passed as an option), by setting
`config.action_view.embed_authenticity_token_in_remote_forms = false`.
Please note that this will break sending those forms with javascript
disabled. If you choose to not generate the token in remote forms by
default, you can still explicitly pass `:authenticity_token => true`
when generating the form to bypass this setting.
The option defaults to `true`, which means that existing apps are
*NOT* affected.

We've also adjusted the dependencies on rack-cache and mail to address
the recent security vulnerabilities with those libraries. If you are
running a vulnerable version of mail or rack-cache you should update
both gems to a safe version. There were also some regressions in the
render method that were fixed in this version.

[1]: http://guides.rubyonrails.org/security.html#mass-assignment

### CHANGES since 3.2.2

*Action Mailer*

* Upgrade mail version to 2.4.3 *ML*


*Action Pack*

* Fix #5632, render :inline set the proper rendered format.
*Santiago Pastorino*

* Fix textarea rendering when using plugins like HAML. Such plugins
encode the first newline character in the content. This issue was
introduced in https://github.com/rails/rails/pull/5191 *James Coleman*

* Do not include the authenticity token in forms where remote: true
as ajax forms use the meta-tag value *DHH*

* Turn off verbose mode of rack-cache, we still have X-Rack-Cache to
check that info. Closes #5245. *Santiago Pastorino*

* Fix #5238, rendered_format is not set when template is not
rendered. *Piotr Sarnacki*

* Upgrade rack-cache to 1.2. *José Valim*

* ActionController::SessionManagement is deprecated. *Santiago Pastorino*

* Since the router holds references to many parts of the system like
engines, controllers and the application itself, inspecting the route
set can actually be really slow, therefore we default alias inspect to
to_s. *José Valim*

* Add a new line after the textarea opening tag. Closes #393 *rafaelfranca*

* Always pass a respond block from to responder. We should let the
responder to decide what to do with the given overridden response
block, and not short circuit it. *sikachu*

* Fixes layout rendering regression from 3.2.2. *José Valim*


*Active Model*

* No changes


*Active Record*

* Added find_or_create_by_{attribute}! dynamic method. *Andrew White*

* Whitelist all attribute assignment by default. Change the default
for newly generated applications to whitelist all attribute
assignment. Also update the generated model classes so users are
reminded of the importance of attr_accessible. *NZKoz*

* Update ActiveRecord::AttributeMethods#attribute_present? to return
false for empty strings. *Jacobkg*

* Fix associations when using per class databases. *larskanis*

* Revert setting NOT NULL constraints in add_timestamps *fxn*

* Fix mysql to use proper text types. Fixes #3931. *kennyj*

* Fix #5069 - Protect foreign key from mass assignment through
association builder. *byroot*


*Active Resource*

* No changes


*Active Support*

* No changes


*Railties*

* No changes


### SHA-1

* SHA-1 (actionmailer-3.2.3.gem) = 04cd2772dd2d402ffb9d9dbf70f5f2256c598ab3
* SHA-1 (actionpack-3.2.3.gem) = 06d51ebd0863e0075d9a3e89a2e48dcc262c4e0c
* SHA-1 (activemodel-3.2.3.gem) = 3f648213b88bb3695e2bce38ff823be99535f401
* SHA-1 (activerecord-3.2.3.gem) = a9810e79d720994abbe24aded2bcb783bb1649b4
* SHA-1 (activeresource-3.2.3.gem) = 3d1de8a80122efbcf6c8b8dfc13a7ab644bb2ca3
* SHA-1 (activesupport-3.2.3.gem) = 6a63d75c798fb87d081cbee9323c46bec4727490
* SHA-1 (rails-3.2.3.gem) = 4db7e5c288f5260dc299d55ec2aad9a330b611fc
* SHA-1 (railties-3.2.3.gem) = 39a887de71350ece12c784d3764b7be2c6659b32

You can find an exhaustive list of changes made between 3.2.2 and
3.2.3 [here](https://github.com/rails/rails/compare/v3.2.2...v3.2.3).

Thanks to everyone for making this possible and enjoy it :).

--

Santiago Pastorino
WyeWorks Co-founder
http://www.wyeworks.com

Twitter: http://twitter.com/spastorino
Github: http://github.com/spastorino

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

Ruby on Rails

Thanks for trying to decipher my problem. I may have made an error in my description of the problem.


Regardless, after much digging, what I am looking for is not currently possible.
https://github.com/rails/rails/issues/919

On Friday, March 30, 2012 6:43:47 AM UTC-7, Tim Shaffer wrote:
I am a little confused here. If ModelB belongs to ModelA, I think your foreign key relationship is backwards. The model_b_table should have a foreign key to model_a_id, not the other way around.

Regardless, though, you can pass conditions to delete_all which should help you accomplish what you want.

ModelA.delete_all("model_b_id is null")

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

Ruby on Rails

I tried out some code in my console and I am having difficulty
translating it for my view and controller so that it gives me the same
result.
My console:

@contract = Contract.new(authnum: "900700", st_date:
"2012-01-01",
end_date: "2012-30-06")

@contract.save

@code = Code.new(code_name: "S-5463", status: "Active",
description: "This and That")

@code.save

@codeline = @code.codelines.build(:units_alloc => "80.00",
:contract => @contract)

@codeline.save

@codeline
=> #<Codeline id: 91, contract_id: 64, code_id: 54, units_alloc:
80.00>

Using pgadmin3 I check my codelines table and I get the same result
namely:

id contract_id code_id units_alloc
91 64 54 80.00

But if I try to run this through my contracts_controller and view I get:

id contract_id code_id units_alloc
91 64 54
92 64 80.00

Here are my models:

class Contract < AR::Base
has_many :codelines
has_many :codes, :through => :codelines

accepts_nested_attributes_for :codes

attr_accessible :codes_attributes,
:codes,:authnum,:st_date,:end_date
end

class Codeline < AR::Base
belongs_to :contract
belongs_to :code
units_alloc ...... this is the attribute I would like to set
end

class Code < AR::Base
has_many :codelines
has_many :contracts, :through => :codelines
end

The new/create action of my app/controllers/contracts_controller.rb

def new
@contract = Contract.new
@contract.codes.build
@contract.codelines.build(:units_alloc => params[:units_alloc],
:contract => @contract)
end

def create
@contract = Contract.new(params[:contract])
if @contract.save
flash[:success] = "New Contract has been saved"
redirect_to @contract
else
@title = "You have some errors"
render 'new'
end
end

the partial for my view in app/views/contracts/_fields.html.haml

= f.fields_for :codes do |ff|
.field
= ff.label :name, "Code Name"
%br/
= ff.text_field :code_name
.field
.
.
= f.fields_for :codelines do |ff|
.field
= ff.label :name, "Units Alloc"
%br/
= ff.text_field :units_alloc

Please have a look to see if you can help me translate my console code
into the appropriate code for my contracts_controller?

Thanks

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

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

Ruby on Rails

I love Cloud based IDEs and really waiting for one which is especially
for Rails with RSpec and hopefully with Cucumber integrated well, as
well as RVM. Instant Heroku and Capistrano deployment would be great,
also SCSS or LESS integration. Thanks for interest,
YogiZoli

On Mar 30, 6:26 pm, "Simon C." <li...@ruby-forum.com> wrote:
> Hi Mark, The potential awesomeness of cloud IDE for RoR can't be
> understated.  I just wish there was a way to make it more mainstream.  A
> lot of folks getting started with Ruby and Rails (ahem, myself included)
> could really benefit if the exo Cloud IDE closely followed the Ruby on
> Rails tutorials with Michael Hartl. However, since the exo Cloud IDE
> seems to be more optimized for javascript event-programming, I would
> probably hold off on using it until it is can be used with the more
> popular rspec, spork, fsevent, ruby gems which enable desktop
> integration testing.  Any idea of whether this functionality will be
> built-in in the near future?
>
> Cheers!
>
> Simon
>
> --
> 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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Ruby on Rails

Hi all,

I just installed cancan on a new project and found out that it creates
some problems with the new scoped mass assignment features of rails 3.2
.

Basically, in my User model I create some attr_accessible attributes in
order to avoid users to edit their roles or other sensitive information.
From the administration I allow admins to edit those protected
attributes by passing :without_protection => true on creation and update
of new users.

This works just fine, but adding cancan load_and_authorize_resource to
my controller triggers a "Can't mass-assign protected attributes:
...stuff..." . This happens also when using something like
User.new(params[:user], :role => :admin)

I really can't figure out how to solve this, so any help would be very
appreciated!

Thanks in advance.

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

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

Ruby on Rails



On Thu, Mar 29, 2012 at 7:28 PM, wbsurfver@yahoo.com <wbsurfver@gmail.com> wrote:
Your post has been very helpful, I tried something like what you
posted, but it didn't
quite make sense to me.

 If you look at what I have currently below, I have to have this
sleep(30) at the bottom which is not optimal.
a join on the thread doesn't work.

 I also tried run_block() instead of run() with no luck.

 I guess if I do everything inside of a EM that doesn't take too long,
it wouldn't matter, but I am trying to get an idea of
how this sort of thing should work

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


require 'eventmachine'

require 'faye'



client = Faye::Client.new('http://localhost:9292/faye')

thr = nil

if !EM.reactor_running?
   thr = Thread.new do
     EM.run do

       puts 'in ev machine'
       client.subscribe('/messages/public') do |message|
         puts message.inspect
       end

       puts '1'

       client.publish('/messages/public', 'username' => 'Joe',
                     'msg' => "hey there againzoggle")
       sleep 10
       puts '2'

       client.publish('/messages/public', 'username' => 'Joe',
                     'msg' => "hey there again")
       puts 'end of ev machine block'
     end
   end

 end

puts 'wait for running'
sleep 0.1 until EM.reactor_running?

sleep 30

puts 'end of client'

Ok, Rails is a single threaded application, once you start event machine inside the application flow, control is lost until a event triggers a return somehow. 
Do not put your code inside the EM block.

This is how i do it


class CommBridge
  
  def self.set_connection
    ensure_reactor_running
    @@client ||= self.set
    @@client
  end

private

   def self.set
     client =   Faye::Client.new("http://localhost:9292/faye", {timeout: 20})
     client.add_extension(ClientAuth.new) 
     return client
   end

  def self.ensure_reactor_running 
        Thread.new { EM.run } unless EM.reactor_running? 
        sleep 0.1 until EM.reactor_running? 
  end
  
  
  
end

class ClientAuth
  def outgoing(message, callback)
    if message['channel'] !~ %r{^/meta/}
     message['ext'] ||= {}
        message['ext']['authToken'] = "#{FAYE_TOKEN}"
  end
  callback.call(message)
  end
end

This calls takes care of creating a client fot he rails server.

Then anywhere in your app

client = CommBridge.set_connection
client.publish("/user/#{channel}",msg.to_json)



 

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

Ruby on Rails

Hi Mark, The potential awesomeness of cloud IDE for RoR can't be
understated. I just wish there was a way to make it more mainstream. A
lot of folks getting started with Ruby and Rails (ahem, myself included)
could really benefit if the exo Cloud IDE closely followed the Ruby on
Rails tutorials with Michael Hartl. However, since the exo Cloud IDE
seems to be more optimized for javascript event-programming, I would
probably hold off on using it until it is can be used with the more
popular rspec, spork, fsevent, ruby gems which enable desktop
integration testing. Any idea of whether this functionality will be
built-in in the near future?

Cheers!

Simon

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

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

Ruby on Rails

hi,

i have a model like this capturing integer values. 

testrun_id
valve_a 
valve_b
valve_c
valve_....n

what i would like to know is how to write an ar-query to find similar records across all valve-values. similar to levenshtein distance, but for integers. i could imagine also grouping some valves-values into a total and compare the totals, but not sure. 
any ideas?

thx


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

Ruby on Rails

I am a little confused here. If ModelB belongs to ModelA, I think your foreign key relationship is backwards. The model_b_table should have a foreign key to model_a_id, not the other way around.


Regardless, though, you can pass conditions to delete_all which should help you accomplish what you want.

ModelA.delete_all("model_b_id is null")

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

Ruby on Rails

On Mar 30, 2012, at 12:34 AM, Kal wrote:

> Hi Walter,
>
> I did as instructed but now getting a "rake aborted! stack level too
> deep (in /home/rubys/work/depot/app/assets/stylesheets/
> scaffolds.css.scss)" error.
>
> I tried to modify "config.assets.compile = true: (from false) within
> config/environments/production.rb but still no good :(

What version of rake? What version of bundler? Have you run bundle install or bundle update on your server? I'm guessing in the dark here, but it sounds like you may not have everything the same on your server as your dev box, version-wise. If you were able to use the site locally, it should work on the server. Try running the site in production on your development machine, using

rake db:migrate RAILS_ENV=production
rake assets:precompile
rails server RAILS_ENV=production

to duplicate the experience locally. See if it's specific to this server.

Also, try prefixing your assets:precompile step on the server with bundle exec so you're sure you're getting the actual versions of everything when you do that.

Walter


>
> Thanks Again,
>
> -Kin
>
> ---------------------------------------------------------------------------------------------------------------------
>
> # rake assets:precompile --trace
>
> ** Invoke assets:precompile (first_time)
> ** Execute assets:precompile
> /usr/local/bin/ruby /usr/local/bin/rake assets:precompile:all
> RAILS_ENV=production RAILS_GROUPS=assets --trace
> ** Invoke assets:precompile:all (first_time)
> ** Execute assets:precompile:all
> ** Invoke assets:precompile:primary (first_time)
> ** Invoke assets:environment (first_time)
> ** Execute assets:environment
> ** Invoke environment (first_time)
> ** Execute environment
> ** Invoke tmp:cache:clear (first_time)
> ** Execute tmp:cache:clear
> ** Execute assets:precompile:primary
> rake aborted!
> stack level too deep
> (in /home/rubys/work/depot/app/assets/stylesheets/
> scaffolds.css.scss)
> /usr/local/lib/ruby/1.9.1/rake/task.rb:162
> Tasks: TOP => assets:precompile:primary
> rake aborted!
> Command failed with status (1): [/usr/local/bin/ruby /usr/local/bin/
> rake as...]
> /usr/local/lib/ruby/1.9.1/rake/file_utils.rb:53:in `block in
> create_shell_runner'
> /usr/local/lib/ruby/1.9.1/rake/file_utils.rb:45:in `call'
> /usr/local/lib/ruby/1.9.1/rake/file_utils.rb:45:in `sh'
> /usr/local/lib/ruby/1.9.1/rake/file_utils_ext.rb:39:in `sh'
> /usr/local/lib/ruby/1.9.1/rake/file_utils.rb:80:in `ruby'
> /usr/local/lib/ruby/1.9.1/rake/file_utils_ext.rb:39:in `ruby'
> /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.1.3/lib/sprockets/
> assets.rake:9:in `ruby_rake_task'
> /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.1.3/lib/sprockets/
> assets.rake:17:in `invoke_or_reboot_rake_task'
> /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.1.3/lib/sprockets/
> assets.rake:25:in `block (2 levels) in <top (required)>'
> /usr/local/lib/ruby/1.9.1/rake/task.rb:205:in `call'
> /usr/local/lib/ruby/1.9.1/rake/task.rb:205:in `block in execute'
> /usr/local/lib/ruby/1.9.1/rake/task.rb:200:in `each'
> /usr/local/lib/ruby/1.9.1/rake/task.rb:200:in `execute'
> /usr/local/lib/ruby/1.9.1/rake/task.rb:158:in `block in
> invoke_with_call_chain'
> /usr/local/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
> /usr/local/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
> /usr/local/lib/ruby/1.9.1/rake/task.rb:144:in `invoke'
> /usr/local/lib/ruby/1.9.1/rake/application.rb:116:in `invoke_task'
> /usr/local/lib/ruby/1.9.1/rake/application.rb:94:in `block (2 levels)
> in top_level'
> /usr/local/lib/ruby/1.9.1/rake/application.rb:94:in `each'
> /usr/local/lib/ruby/1.9.1/rake/application.rb:94:in `block in
> top_level'
> /usr/local/lib/ruby/1.9.1/rake/application.rb:133:in
> `standard_exception_handling'
> /usr/local/lib/ruby/1.9.1/rake/application.rb:88:in `top_level'
> /usr/local/lib/ruby/1.9.1/rake/application.rb:66:in `block in run'
> /usr/local/lib/ruby/1.9.1/rake/application.rb:133:in
> `standard_exception_handling'
> /usr/local/lib/ruby/1.9.1/rake/application.rb:63:in `run'
> /usr/local/bin/rake:32:in `<main>'
> Tasks: TOP => assets:precompile
>
> ---------------------------------------------------------------------------------------------------------------------
>
> On Mar 29, 11:37 pm, Walter Lee Davis <wa...@wdstudio.com> wrote:
>> On Mar 29, 2012, at 10:51 PM, Kal wrote:
>>
>>> (Re-posting)
>>
>>> Thanks Walter,
>>
>>> I think you are correct. I had neglected to set up a production
>>> version of the database.
>>
>>> I just ran "rake db:migrate RAILS_ENV=production". However, I now get
>>> a "500 Internal Server Error".
>>
>>> Anyway, here is the error from production.log. Any ideas?
>>
>> Sure. rake assets:precompile and you should be good to go.
>>
>> Walter
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> Thanks,
>>
>>> Kal
>>
>>> -----------------------------------------------------------------------------------------------------------------------------
>>
>>> Processing by StoreController#index as HTML
>>> Rendered store/index.html.erb within layouts/application (17.9ms)
>>> Completed 500 Internal Server Error in 38ms
>>
>>> ActionView::Template::Error (all.css isn't precompiled):
>>> 2: <html>
>>> 3: <head>
>>> 4: <title>Depot</title>
>>> 5: <%= stylesheet_link_tag :all %>
>>> 6: <%= javascript_include_tag :defaults %>
>>> 7: <%= csrf_meta_tag %>
>>> 8: </head>
>>> app/views/layouts/application.html.erb:5:in
>>> `_app_views_layouts_application_html_erb__750878_73537400'
>>
>>> ---------------------------------------------------------------------------------------------------------------------------
>>
>>> On Mar 29, 4:12 pm, Walter Lee Davis <wa...@wdstudio.com> wrote:
>>>> On Mar 28, 2012, at 8:56 PM, Kal wrote:
>>
>>>>> Hi All,
>>
>>>>> Can someone please help? I've been banging my head against for wall
>>>>> for 2 months; all of which has been spent trying to set up ROR. So I
>>>>> actually haven't written 1 line of code :( Any help would be greatly
>>>>> appreciated :)
>>
>>>>> I'm following the 4th edition of "Agile Web Development with Rails".
>>>>> So, I'm able to deploy the site via WEBrick. However, when I go to my
>>>>> URL (without using port 3000), I get the error message below. What am
>>>>> I missing?
>>>>> ---------------------------------------------------------------------------------------------------------------
>>
>>>>> Ruby (Rack) application could not be started
>>>>> These are the possible causes:
>>
>>>>> There may be a syntax error in the application's code. Please check
>>>>> for such errors and fix them. A required library may not installed.
>>>>> Please install all libraries that this application requires. The
>>>>> application may not be properly configured. Please check whether all
>>>>> configuration files are written correctly, fix any incorrect
>>>>> configurations, and restart this application. A service that the
>>>>> application relies on (such as the database server or the Ferret
>>>>> search engine server) may not have been started. Please start that
>>>>> service.
>>
>>>>> Further information about the error may have been written to the
>>>>> application's log file. Please check it in order to analyse the
>>>>> problem.
>>
>>>>> Error message:
>>>>> unable to open database file (SQLite3::CantOpenException)
>>>>> Exception class:
>>>>> PhusionPassenger::UnknownError
>>>>> Application root:
>>>>> /home/rubys/work/depot
>>>>> Backtrace
>>
>>>>> ---------------------------------------------------------------------------------------------------------------
>>
>>>>> This is the error in /var/log/httpd/error_log
>>
>>>>> *** Exception PhusionPassenger::UnknownError in
>>>>> PhusionPassenger::Rack::ApplicationSpawner (unable to open database
>>>>> file (SQLite3::CantOpenException)) (process 3244, thread #<Thread:
>>>>> 0xa1db870>):
>>
>>>>> ---------------------------------------------------------------------------------------------------------------
>>
>>>>> By the way, I'm running:
>>
>>>>> Ruby 1.9.3p0
>>>>> Rails 3.1.3
>>>>> Phusion Passenger version 3.0.11
>>>>> CentOS release 5.6
>>>>> Server version: Apache/2.2.3
>>
>>>>> ---------------------------------------------------------------------------------------------------------------
>>
>>>>> This my vhost configuration from httpd.conf
>>
>>>>> <VirtualHost *:80>
>>>>> ServerNamewww.mywebpage.com
>>>>> DocumentRoot /home/rubys/work/depot/public/
>>
>>>>> <Directory /home/rubys/work/depot/public>
>>>>> Order allow,deny
>>>>> Allow from all
>>>>> </Directory>
>>
>>>>> </VirtualHost>
>>
>>>> By any chance, have you run rake:db:migrate RAILS_ENV=production yet? If not, then one possible reason why you can't open the database is that it does not exist.
>>
>>>> Walter
>>
>>> --
>>> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
>>> To post to this group, send email to rubyonrails-talk@googlegroups.com.
>>> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
>>> For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>

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

Ruby on Rails

I'm using Rails -3.2.1. In one of my form I'm using jquery validation.
My form is below

----------------------------------------------------------------------
new_account.html.erb

<%= form_for(@account, :url =>{:action=> "create_account"}) do |f| %>

<table width="80%" border="1" align="center" cellpadding="5"
cellspacing="5">
<tr>
<td width="30%">
<%= f.label :Account_Name, :class => :style1_bold %>
</td>
<td>
<%= f.text_field :account_name, :class =>"input_border required
ONLY_ALPHABET" %>
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
<td>
<%=f.submit "Add Account" %>
<%= link_to "Cancel", home_path, :class=>"style2_link" %>
</td>
</tr>
</table>
<% end %>
----------------------------------------------------------------------
In application.js

//= require jquery
//= require jquery_ujs
// require_tree .
//= require_directory .

jQuery.noConflict();
jQuery(document).ready(function(){

/////////////////////////////////////////////
//// Validatior for only alphabet
/////////////////////////////////////////////
jQuery.validator.addMethod("ONLY_ALPHABET",function(value,element){
return this.optional(element) || /^[a-zA-Z
]+$/.test(value);
},"Only Alphabet is allowed");

/////////////////////////////////////////////
//// Validation for Create Account
/////////////////////////////////////////////
jQuery("#new_account").validate(
{
rules: {
account_account_name: {
required: true,
ONLY_ALPHABET: true,
maxlength: 30
}
},
messages: {
account_account_name: {
required: "Please fill category",
ONLY_ALPHABET: "Only Alphabet is allowed",
maxlength: "Not more than 30 characters"
}
}
});

});
----------------------------------------------------------------------
On Form submit. It doesn't show my message instead it show jquery
default messages.

I include this file jquery.validate.min.js

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

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

Ruby on Rails

user_name=auth_decoded[0]
          password=auth_decoded[1]
          @user = User.find_by_email(user_name)
          if (@chkuser= (@user && @user.authenticate(password))) 


in  the above code, this  @user.authenticate(password)  return false......

Why like this....?
Thank you
vishnu

On Friday, 30 March 2012 06:56:21 UTC-4, amvis wrote:


>On Friday, 30 March 2012 04:25:48 UTC-4, Aaron Schmitz wrote:
>i don't know where "user_name" comes from but i think you are passing
>in user_name where you search for the email.
 
 i think thats not a pblm, bcz here user_name basically that is an email address for login purpose, Have any another issues with that code? 

Thank you
vishnu

 
>"@user = User.find_by_email(user_name)"

>change it to:

>"@user = User.find_by_email(user_email)" or however your variable is
called

>greets

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

Ruby on Rails

Can you paste the exact error that you are getting?

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

Ruby on Rails

can anyone shed any light on this...

two questions.

1) do the new relationships via the join table look wrong (hence the
console error)
2) does my data_mover script look OK?

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

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

Ruby on Rails

Hello,

I want to add a Partner property to more than one type of models (ie.
SalesOrder and PurchaseOrder).
Is this the proper way of defining associatons or there's a simpler
way?

class Partner < ActiveRecord::Base
has_many :sales_orders
has_many :purchase_orders
end

class SalesOrder < ActiveRecord::Base
belongs_to :partner
end

class PurchaseOrder < ActiveRecord::Base
belongs_to :partner
end

Thanks

Zoltan

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

Ruby on Rails



>On Friday, 30 March 2012 04:25:48 UTC-4, Aaron Schmitz wrote:

>i don't know where "user_name" comes from but i think you are passing
>in user_name where you search for the email.
 
 i think thats not a pblm, bcz here user_name basically that is an email address for login purpose, Have any another issues with that code? 

Thank you
vishnu

 
>"@user = User.find_by_email(user_name)"

>change it to:

>"@user = User.find_by_email(user_email)" or however your variable is
called

>greets

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

Ruby on Rails

I been working on image upload since long and every time working fine,

Now since i deployed application on server,i am facing strange problem
while image upload.

When i am trying upload image it's gives error like,

NameError (undefined method path' for
classActionController::UploadedStringIO'): :10:in synchronize' passenger
(3.0.9)
lib/phusion_passenger/rack/request_handler.rb:96:inprocess_request'
passenger (3.0.9)
lib/phusion_passenger/abstract_request_handler.rb:513:in
accept_and_process_next_request' passenger (3.0.9)
lib/phusion_passenger/abstract_request_handler.rb:274:inmain_loop'
passenger (3.0.9)
lib/phusion_passenger/classic_rails/application_spawner.rb:321:in
start_request_handler' passenger (3.0.9)
lib/phusion_passenger/classic_rails/application_spawner.rb:275:inblock
in handle_spawn_application' passenger (3.0.9)
lib/phusion_passenger/utils.rb:479:in safe_fork' passenger (3.0.9)
lib/phusion_passenger/classic_rails/application_spawner.rb:270:inhandle_spawn_application'
passenger (3.0.9) lib/phusion_passenger/abstract_server.rb:357:in
server_main_loop' passenger (3.0.9)
lib/phusion_passenger/abstract_server.rb:206:instart_synchronously'
passenger (3.0.9) lib/phusion_passenger/abstract_server.rb:180:in start'
passenger (3.0.9)
lib/phusion_passenger/classic_rails/application_spawner.rb:149:instart'
passenger (3.0.9) lib/phusion_passenger/spawn_manager.rb:219:in block (2
levels) in spawn_rails_application' passenger (3.0.9)
lib/phusion_passenger/abstract_server_collection.rb:132:inlookup_or_add'
passenger (3.0.9) lib/phusion_passenger/spawn_manager.rb:214:in block in
spawn_rails_application' passenger (3.0.9)
lib/phusion_passenger/abstract_server_collection.rb:82:inblock in
synchronize' :10:in synchronize' passenger (3.0.9)
lib/phusion_passenger/abstract_server_collection.rb:79:insynchronize'
passenger (3.0.9) lib/phusion_passenger/spawn_manager.rb:213:in
spawn_rails_application' passenger (3.0.9)
lib/phusion_passenger/spawn_manager.rb:132:inspawn_application'
passenger (3.0.9) lib/phusion_passenger/spawn_manager.rb:275:in
handle_spawn_application' passenger (3.0.9)
lib/phusion_passenger/abstract_server.rb:357:inserver_main_loop'
passenger (3.0.9) lib/phusion_passenger/abstract_server.rb:206:in
start_synchronously' passenger (3.0.9)
helper-scripts/passenger-spawn-server:99:in'

(500 Internal Server Error)

but when i am trying second time it working very fine. Any idea ?

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

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