Ruby on Rails Saturday, June 30, 2012

Thanks a lot Hassan, I tryed with tasks.first.project and everything is
OK.

Thanks again.

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

Ruby on Rails

On Sat, Jun 30, 2012 at 4:17 PM, Felipe Pieretti Umpierre
<lists@ruby-forum.com> wrote:

> irb(main):001:0> task = Task.all

Model.all is clearly intended to return multiple results; it would be
more appropriate to say `tasks = Task.all`

> irb(main):002:0> task.project
> NoMethodError: undefined method `project' for #<Array:0x482b068>

in which case you would be calling e.g.

tasks.first.project
or
tasks.each{ |task| puts task.project.inspect }
or whatever

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
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-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-US.

Ruby on Rails

Could this be done with fields_for?

On Friday, 29 June 2012 15:02:52 UTC-6, sheamus wrote:

Say I have a Dog that has_may legs (In this case we don't care how many).  In the _form for Dog, I would like to assign a pre-existing let to him.  I would like to do something like this:

<%= f.collection_select :leg_1, Leg.select { |l| l.dog_id == nil }, :id, :description %>
<%= f.collection_select :leg_2, Leg.select { |l| l.dog_id == nil }, :id, :description %>

Then in my controller's create action:

@dog = Dog.new(params[:dog])
@dog.save
leg = Leg.find(params[:leg_1])
leg.dog = @dog
leg.save

The problem is that the collection_select is trying to set the leg_1 value as part of Dog, which of course does not exist. Do I need to create 'view model' for doing this?

Thanks,
~S

--
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/-/FJhqhsHfyWYJ.
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-US.

Ruby on Rails

Hello Colin, thank you for your answer..

I tryed this:

irb(main):001:0> task = Task.all
←[1m←[36mTask Load (1.0ms)←[0m ←[1mSELECT `tasks`.* FROM `tasks` ←[0m
←[1m←[35mEXPLAIN (1.0ms)←[0m EXPLAIN SELECT `tasks`.* FROM `tasks`
EXPLAIN for: SELECT `tasks`.* FROM `tasks`
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows |
Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
| 1 | SIMPLE | tasks | ALL | NULL | NULL | NULL | NULL | 2 |
|
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
1 row in set (0.00 sec)

=> [#<Task id: 1, user_id: nil, project_id: 1, name:
"W\r<br>T\r<br>F ?\r<br>VERY\r<br...", del
eted: 0, done: 0, created_at: "2012-06-24 15:46:37", updated_at:
"2012-06-30 17:13:27">, #<Task id: 2, user_id: nil, pro
ject_id: 1, name: "Teste", deleted: 0, done: 0, created_at: "2012-06-30
17:11:27", updated_at: "2012-06-30 17:11:27">]
irb(main):002:0> task.project
NoMethodError: undefined method `project' for #<Array:0x482b068>
from (irb):2
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands/console.rb:47:in
`start'
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands/console.rb:8:in
`start'
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:41:in
`<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

But when I try to call task.project a error shows up, and if I put
task.id the same error is print

Thank you

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

Ruby on Rails

aash dhariya wrote in post #1066730:
> I think you are using gsub on symbol which is the reason you are thrown
> this error. Pass the string to the function instead of symbol:
> <%= dropdown_tags "sort_criteria", 'Select Criteria',
> %w(Category Status Amount-High Amount-Low) %>
>
> On Sat, Jun 30, 2012 at 3:52 AM, Eastside Developer
> <lists@ruby-forum.com>wrote:
>
>> ) and placed it in /lib
>> <% require 'jquery_dropdown_helper' %>
>>
>> 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-US.
>>
>>
>
>
> --
> Thanks,
> Aash

Yes, gsub as a method is not going to act on a symbol. However, when I
switch to string, instead of seeing a dropdown menu, I see the
following: note that I changed the name of the hidden tag). Any pointers
to dropdown menu examples that do not force to do a deep dive into
JQuery?

<a id="admin_menu_selection-selector" class="fg-button
fg-button-icon-right ui-widget ui-corner-all ui-state-default"
href="#admin_menu_selection-selector-items" tabindex="0" > <span
class="ui-icon ui-icon-triangle-1-s"></span>Admin</a> <div
id="admin_menu_selection-selector-items" class="hidden" ><ul><li><a
href="#" value="Category">Category</a></li> <li><a href="#"
value="Status">Status</a></li> <li><a href="#"
value="Amount-High">Amount-High</a></li> <li><a href="#"
value="Amount-Low">Amount-Low</a></li></ul></div> <script
type="text/javascript"> jQuery('#admin_menu_selection-selector').menu({
content: jQuery('#admin_menu_selection-selector-items').html(), flyOut:
true, posX: 'left', posY: 'bottom', directionV: 'down', maxHeight: 400,
detectV: false, showSpeed: 350, chooseItem: function(selection) {
jQuery('#admin_menu_selection-selector').html( '<span class="ui-icon
ui-icon-triangle-1-s"></span>' + jQuery(selection).text() ); var vid =
jQuery(selection).attr('value');
jQuery('#admin_menu_selection').attr('value', vid); (vid); } });
</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-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-US.

Ruby on Rails

On 30 June 2012 18:36, Felipe Pieretti Umpierre <lists@ruby-forum.com> wrote:
> Hello guys, I have two tables, tasks and projects, and each model I put:
>
> Task.rb
>
> class Task < ActiveRecord::Base
> attr_accessible :user_id, :project_id, :name
> belongs_to :project
> end
>
> Project.rb
>
> class Project < ActiveRecord::Base
> attr_accessible :name, :description
> has_many :tasks
> end
>
> But when I go to my prompt and I make a SELECT with task, none project
> is returned.
>
> irb(main):001:0> Task.all
> ←[1m←[36mTask Load (0.0ms)←[0m ←[1mSELECT `tasks`.* FROM `tasks` ←[0m
> ←[1m←[35mEXPLAIN (30.0ms)←[0m EXPLAIN SELECT `tasks`.* FROM `tasks`
> EXPLAIN for: SELECT `tasks`.* FROM `tasks`
> +----+-------------+-------+------+---------------+------+---------+------+------+-------+
> | id | select_type | table | type | possible_keys | key | key_len | ref | rows |
> Extra |
> +----+-------------+-------+------+---------------+------+---------+------+------+-------+
> | 1 | SIMPLE | tasks | ALL | NULL | NULL | NULL | NULL | 2 |
> |
> +----+-------------+-------+------+---------------+------+---------+------+------+-------+
> 1 row in set (0.03 sec)
>
> => [#<Task id: 1, user_id: nil, project_id: 1, name:
> "W\r<br>T\r<br>F\r<br>VERY\r<br...", del
> eted: 0, done: 0, created_at: "2012-06-24 15:46:37", updated_at:
> "2012-06-30 17:13:27">, #<Task id: 2, user_id: nil, pro
> ject_id: 1, name: "Teste", deleted: 0, done: 0, created_at: "2012-06-30
> 17:11:27", updated_at: "2012-06-30 17:11:27">]
>
> I guess the project name should come too ? right ?
>
> What am I doing wrong ?

Nothing. The project will only be fetched if you use :include in the
query. However, for one of the tasks fetched above you can still say
task.project and it will fetch the project then.

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

Ruby on Rails

Hello everybody. Anybody using AR + Mongoid in the same project and had problems with db:schema:load ?

When I run the task with mongoid gem in my Gemfile the AR models are loaded during the enviroment boot and it complains that model's table doesn't exist (obviously, I'm trying to create it)

Best regards.


--
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/-/k4mbRibkv0gJ.
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-US.

Ruby on Rails

when i try  /contact_mail/newi it return me error: undefined local variable or method `em' for #<#<Class:0x007fca24248858>:0x007fca21186df0>





model: contact_mail.rg
class ContactMail < ActiveRecord::Base
  attr_accessible :email, :message, :name, :subject

end

controler: contarct_mail_controller.rb
class ContactMailController < ApplicationController
 def new 
    @em=ContactMail.new
  end
  
  def create
    @em = ContactMail.new(params[:contact_mail])
    @em.save
  end
    
end


view: new.html.erb
<%= form_for(@em) do |f| %>
<div class="field">
<%= f.label :email %>
<%= f.text_field :email%><br />
<br />
</div>
<div class="actions">
<%= f.submit "wyslij" %><br />
</div>
<% end %>



when i add @em.save to def new in controller it pass but i't not the way i want to do it.
Do enyone know how can i fix it? or what is wrong with my solution? 

i had made 4 model and controllers allrady using this method and it works perfetly. 

i had add resources :contact_mail to routes. 




--
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/-/BH5lDzwUeEAJ.
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-US.

Ruby on Rails

On Sat, Jun 30, 2012 at 10:36 AM, Felipe Pieretti Umpierre
<lists@ruby-forum.com> wrote:

> irb(main):001:0> Task.all

> => [#<Task id: 1, user_id: nil, project_id: 1, name:
> "W\r<br>T\r<br>F\r<br>VERY\r<br...", del
> eted: 0, done: 0, created_at: "2012-06-24 15:46:37", updated_at:
> "2012-06-30 17:13:27">, #<Task id: 2, user_id: nil, pro
> ject_id: 1, name: "Teste", deleted: 0, done: 0, created_at: "2012-06-30
> 17:11:27", updated_at: "2012-06-30 17:11:27">]
>
> I guess the project name should come too ? right ?

Wrong.

> What am I doing wrong ?

Misunderstanding ActiveRecord and associations :-)

Revisiting the relevant Rails guides might be a good idea.

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
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-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-US.

Ruby on Rails

Hello guys, I have two tables, tasks and projects, and each model I put:

Task.rb

class Task < ActiveRecord::Base
attr_accessible :user_id, :project_id, :name
belongs_to :project
end

Project.rb

class Project < ActiveRecord::Base
attr_accessible :name, :description
has_many :tasks
end

But when I go to my prompt and I make a SELECT with task, none project
is returned.

irb(main):001:0> Task.all
←[1m←[36mTask Load (0.0ms)←[0m ←[1mSELECT `tasks`.* FROM `tasks` ←[0m
←[1m←[35mEXPLAIN (30.0ms)←[0m EXPLAIN SELECT `tasks`.* FROM `tasks`
EXPLAIN for: SELECT `tasks`.* FROM `tasks`
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows |
Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
| 1 | SIMPLE | tasks | ALL | NULL | NULL | NULL | NULL | 2 |
|
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
1 row in set (0.03 sec)

=> [#<Task id: 1, user_id: nil, project_id: 1, name:
"W\r<br>T\r<br>F\r<br>VERY\r<br...", del
eted: 0, done: 0, created_at: "2012-06-24 15:46:37", updated_at:
"2012-06-30 17:13:27">, #<Task id: 2, user_id: nil, pro
ject_id: 1, name: "Teste", deleted: 0, done: 0, created_at: "2012-06-30
17:11:27", updated_at: "2012-06-30 17:11:27">]

I guess the project name should come too ? right ?

What am I doing wrong ?

Thank you

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

Ruby on Rails

On 30 June 2012 16:10, Scott Ribe <scott_ribe@elevated-dev.com> wrote:
> - I need to create a daemon process that runs periodically in the background on a server and creates some export files from a database.
>
> - I'd like to write it in Ruby and use ActiveRecord & ERB.
>
> - Conveniently enough, I'm actually working on an RoR app that will be deployed on this server, against the same database, within a few months. So I might as well go ahead with a full RoR install on the server--no need to pick and choose gems.
>
> - This daemon process I want to create now really is not connected to that app, and so should live entirely outside that app's directory structure.
>
> I think it's that last point that I don't quite know what to do about. My standalone daemon would, I guess, require ActiveXXX and a model.rb file (or 2 or 3). Or perhaps no model file, just define the model classes inline. (This daemon could easily fit in a single source file; the model files will basically be empty.)

If the code is fetching data from the database then put most of the
code in the model in the rails app and run it with a rake task,
possibly from cron. By putting it in the model you can test the
methods using the rails tests.

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

Ruby on Rails

On Sat, Jun 30, 2012 at 8:10 AM, Scott Ribe <scott_ribe@elevated-dev.com> wrote:
> - I need to create a daemon process that runs periodically in the background on a server and creates some export files from a database.

A "daemon" process runs continuously; are you sure you don't just
want to use cron? It's made for "periodically" :-)

> - I'd like to write it in Ruby and use ActiveRecord & ERB.

If cron is an option, you could either write a standalone script, a rake
task or use a full Rails installation and `rails runner`.

FWIW,
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
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-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-US.

Ruby on Rails

Our client are seeking a talented Ruby developer to join their IT team. 

Moving to JRuby from Windows, our Client are seeking an ambitious developer who will help deliver their state-of-the-art API platfom. 

If this sounds like you then please read below for more information. 

The ideal candidate will be: 

An expert in Ruby, having a track record of solving difficult and complex problems efficiently and elegantly; 
In depth knowledge of the Ruby ecosystem; 
Can manage projects through full software life cycle; 
Can mentor and encourage junior developers; 
Can document and articule ideas clearly and is unafraid to express opinions. 

Essential requirements: 

Ruby - Sinatra/Padrino/Sequel/TorqueBox; 
Experience leadingothers; 
Passion for web development and technology; 
Experience with Javascript frameworks, JQuery etc; 
expert web stack knowledge - HTTP, CSS, REST. 

Permanent position for Eu Citizen or Visa holders. 

Location: Dublin, Ireland. 

Language: English Fluent. 

Salary: +55K euro plus benefits. 

If you are interested please send to me your resume in word format, a cover letter, salary, notice period and availability with Ref. Ruby Dev. to angelo.chirulli@pentasia.com 

Website: http://www.pentasia.com 

Thank you in advance for your time.

The client is an Equal Opportunity Employer (EOE).  

--
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/-/ByvUGkH7p60J.
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-US.

Ruby on Rails

- I need to create a daemon process that runs periodically in the background on a server and creates some export files from a database.

- I'd like to write it in Ruby and use ActiveRecord & ERB.

- Conveniently enough, I'm actually working on an RoR app that will be deployed on this server, against the same database, within a few months. So I might as well go ahead with a full RoR install on the server--no need to pick and choose gems.

- This daemon process I want to create now really is not connected to that app, and so should live entirely outside that app's directory structure.

I think it's that last point that I don't quite know what to do about. My standalone daemon would, I guess, require ActiveXXX and a model.rb file (or 2 or 3). Or perhaps no model file, just define the model classes inline. (This daemon could easily fit in a single source file; the model files will basically be empty.)

Thoughts?

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice




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

Ruby on Rails

On 30 June 2012 14:37, tanizawa <kazuyat7175@gmail.com> wrote:
> I almost use normal ActiveRecord methods.
> I use find_by_sql for complected sql.

Why are you joining main.id on sub.id? Normally that would be
considered poor database design. It would be usual to use a has_one
belongs_to relationship, then you could use an ActiveRecord query.
Also your table names should be plural to follow the Rails
conventions.

By the way, please don't top post, it makes it difficult to follow the
thread. Insert your reply inline. Thanks.

Colin

>
> 2012年6月30日土曜日 18時17分48秒 UTC+9 Colin Law:
>>
>> On 30 June 2012 10:08, tanizawa <kazuyat7175@gmail.com> wrote:
>> > hi
>> > I amd tanizawa.
>> >
>> > I had problem.
>> > I can not get main.name value from below sql.
>> > "find_by_sql 'select main.id,main.name,sub.name from main left join
>> > sub on
>> > sub.id = main.id'"
>> > Please teach me how to get borth name value.
>>
>> My first question would be why are you using find_by_sql? Why not use
>> the normal rails ActiveRecord methods. See
>> http://guides.rubyonrails.org/active_record_querying.html
>> and
>> http://guides.rubyonrails.org/association_basics.html
>>
>> I assume you have already worked through the getting started guide and
>> some tutorials such as railstutorial.org which is free to use online.
>>
>> Colin
>
> --
> 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/-/Y0cbAv-VbxAJ.
>
> 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-US.

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

Ruby on Rails

hello, im implementing a Category and subcategory. However, it archieve
it using only 1 model with the gem 'awesome_nested_set' ,so when i click
my first collection_Select,it will process my ajax and return a instant
variable for my controller and get the category for the second
collection select.
I almost done it ,but left some little problem,

1. when i load the page , it give me error "might expect an instant of
array"
i knw why this come from ,its because ,when i load the page ,it actually
load the js, but initialy, i havent click the first collection_select,do
i cannot get the value from the select and my controller cannot get the
params from there too.
2.i did try to dont run the partial ,but my firebug console show me red
color ,but i see it can get the params from the first collection_select
edy.

Here is my gist.gihub
https://gist.github.com/2995276
full code is provided, please guide me ,i need some modification then
can do it edy.. @@

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

Ruby on Rails

I almost use normal ActiveRecord methods.

I use find_by_sql for complected sql.

2012年6月30日土曜日 18時17分48秒 UTC+9 Colin Law:
On 30 June 2012 10:08, tanizawa <kazuyat7175@gmail.com> wrote:
> hi
> I amd tanizawa.
>
> I had problem.
> I can not get main.name value from below sql.
>   "find_by_sql 'select main.id,main.name,sub.name from main left join sub on
> sub.id = main.id'"
> Please teach me how to get borth name value.

My first question would be why are you using find_by_sql?  Why not use
the normal rails ActiveRecord methods.  See
http://guides.rubyonrails.org/active_record_querying.html
and
http://guides.rubyonrails.org/association_basics.html

I assume you have already worked through the getting started guide and
some tutorials such as railstutorial.org which is free to use online.

Colin

--
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/-/Y0cbAv-VbxAJ.
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-US.

Ruby on Rails

before(:all) seems well-suited to this problem. It creates data that persists across transactions. 


https://www.relishapp.com/rspec/rspec-rails/docs/transactions


--
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/-/7CQaUNZU_RIJ.
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-US.

Ruby on Rails

On 30 June 2012 10:08, tanizawa <kazuyat7175@gmail.com> wrote:
> hi
> I amd tanizawa.
>
> I had problem.
> I can not get main.name value from below sql.
> "find_by_sql 'select main.id,main.name,sub.name from main left join sub on
> sub.id = main.id'"
> Please teach me how to get borth name value.

My first question would be why are you using find_by_sql? Why not use
the normal rails ActiveRecord methods. See
http://guides.rubyonrails.org/active_record_querying.html
and
http://guides.rubyonrails.org/association_basics.html

I assume you have already worked through the getting started guide and
some tutorials such as railstutorial.org which is free to use online.

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

Ruby on Rails

hi
I amd tanizawa.

I had problem.
I can not get main.name value from below sql.
  "find_by_sql 'select main.id,main.name,sub.name from main left join sub on sub.id = main.id'"
Please teach me how to get borth name value.

--
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/-/_75fIh9qaQ4J.
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-US.

Ruby on Rails

Hey, are you still looking for someone, the post was some time ago so I am guessing not, be please let me know if so.



On Wednesday, 6 April 2011 17:38:53 UTC+3, mgreenly wrote:

Ruby/Rails - Contract Position Available

I'm looking for an experienced Ruby/Rails programmer to essentially remote pair with me for the development of an open source Rails 3 plugin.

The plugin is an interface to the Datatables library (http://www.datatables.net/). 

My goal is to create an extremely intuitive API for the average rails developer that will expose all of the functionality of the Datatables library.  Including multi column sorting, per column filtering, etc…  In addition, considerable focus will be applied to ensure that the database is accessed efficiently.

The right person will be…

  • an experienced Ruby and Rails developer
  • have some knowledge of how Rails plugins are constructed even if they've never published one
  • have a solid understanding of ActiveRecord and not be afraid of methods like reflect_on_associations
  • should be comfortable with test driven development
  • should know RSpec or be willing to learn it
  • should be proficient with Git.


In addition we'll be working together remotely so you'll need to be willing to use Skype, VNC and what ever other tools would help.

The resulting library will be distributed under the MIT and GPL license.

This is a short term contract for an open source project.  I'm willing to pay competitive contractor rates.  I expect the job to last between 80 to 120 hours total and to spend 20-40 hours a week on it. 

I'm willing to be flexible with my schedule and match yours if necessary.

Mike Greenly

http://logic-refinery.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/-/c1I5_PhLjUcJ.
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-US.

Ruby on Rails Friday, June 29, 2012

I think you are using gsub on symbol which is the reason you are thrown this error. Pass the string to the function instead of symbol:

<%= dropdown_tags "sort_criteria", 'Select Criteria',
   %w(Category Status Amount-High Amount-Low) %>

On Sat, Jun 30, 2012 at 3:52 AM, Eastside Developer <lists@ruby-forum.com> wrote:
Environment: Rails 3.2.3

This is my first attempt at doing a dropdown menu in a Rails
application. I tried looking for help on the topic, but what complicated
things is that the term dropdown menu is used for actual dropdown menu
(page menu), as well as what is dropdown lists, form options, form
selections, etc.

I found a pointer to https://github.com/dkeskar/rails-jquery-dropdown,
and following the instructions, I downloaded jquery_dropdown_helper.rb:
) and placed it in /lib

In my Gemfile, I have the following:

gem 'jquery-rails'

I downloaded jquery_dropdown_helper.rb:
https://github.com/dkeskar/rails-jquery-dropdown) and placed it in /lib

In _header.html.erb, I have the following:

<% require 'jquery_dropdown_helper' %>
....
<%= hidden_field_tag :sort_criteria %>
<%= dropdown_tags :sort_criteria, 'Select Criteria',
   %w(Category Status Amount-High Amount-Low) %>

Here's the error code I'm getting:

undefined method `gsub' for :sort_criteria:Symbol

Any ideas?

Attached is the jquery_dropdown_helper.rb

Attachments:
http://www.ruby-forum.com/attachment/7541/jquery_dropdown_helper.rb


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




--
Thanks, 
Aash

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

Ruby on Rails



On Wednesday, June 27, 2012 12:54:41 PM UTC-4, Ylan wrote:

On Jun 27, 2012, at 9:42 AM, Vell wrote:

>
> The error you are getting means that, when running the rake task the jquery gem is not available. There are a few ways this can happen: Did you add the jquery gem only in the development group? In the asset group?
>
> jquery rails is in the assets group of my gemfile
>  
> Did you remember to run bundle install after adding the gem?
>
> Yes I did run bundle install after adding the gym.
>  
> What bundler groups are available in which environments (look into your application.rb file).
>
> I am not sure I am looking in the right place in my application.rb file but here is what I saw at the top of the file:
>
> if defined?(Bundler)
>   # If you precompile assets before deploying to production, use this line
>   Bundler.require(*Rails.groups(:assets => %w(development test)))
>   # If you want your assets lazily compiled in production, use this line
>   # Bundler.require(:default, :assets, Rails.env)
> end
>
> If answering the above questions doesn't lead you to find the problem, post back your complete Gemfile and we will go from there.
>
> Here is what my gemfile looks like:
>
[snip]

I don't see any obvious errors there, and I am assuming that you already checked line 13 of application.js for correctness. At this point, I am out of ideas on where the problem is. If I where you, I would start a blank rails application in which you *can* precompile the assets. Then starts looking for potential differences between the brand new app and yours.

So I did end up resolving this issue. There were 2 issues.

1. jquery-rails doesn't like being in the assets block of my Gemfile. Once I took it out of that block I was able to compile in production without any error. I happened to be passing through railscast and saw that one of Ryan Bates examples had that particular line under the assets block.

2. I had an error in one of my .js files so removed the file and everything seems to be working as expected. I will see if I can figure out what is going on with that .js file at a later date.

Thanks for the help in trying to get me to solve this issue.

Sorry, I can't be of more help.

--
Ylan


--
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/-/PrE1Kr1OuyIJ.
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-US.

Ruby on Rails

Rails 3.2.1 Ruby 1.9.3p125 Rspec 2.8.0
I have a utility written in ruby that executes within a Rails
environment. It creates database records in one table based on the info
in other tables. A date and a name determine uniqueness of these created
records.

To test this, I have to run the utility giving it date parameters for a
year + 4 days and then, for each test, test to see if each of 34 records
has or has not been created according to a spreadsheet that contains the
expected result.

The utility creates records according to a number of different
algorithms so that, for example, on the 21st of the month it may create
a record for the 19th and another for the 31st, so it's not feasible to
run this on a day-by-day basis.

The thing is, I don't want to have to run the utility inside every test
- it takes several minutes for each run and there will be 34 x 366 tests
(plus a few extras).

So, I run the utility and then, when I execute the first test, I
discover that the records created by the utility are gone and the
database contains just the fixtures data.

Roughly, I have:

describe "comprehensive test" do
context "all year" do
<utility to extract infrastructure data from dev database>
<code to symlink a yaml file with one or another mutually exclusive
seed records>
fixtures :all
<execute utility for 2012-01-01 to 2013-01-05>
it "should have more than the seed records in the table examined" do
Table.all.count.should be > 2 # number of seed records
end
<each day, each identifier, try to retrieve record and check against
0 or 1 on the corresponding spreadsheet entry>
end
context "already existing records" do
<empty database>
<code to symlink the other yaml file into a fixture>
fixtures :all
<execute utility for 2012-05-31 only>
<test that a specific 6 records have not been created>
end
end

One test actually implemented and it fails.

The one test will be followed by complex looping code reading the
spreadsheet and requesting the corresponding record and either it should
be there or it shouldn't. That's over 12,000 tests because not creating
a record when it shouldn't be there is as important as creating it when
it should. And then there's the second context...

Running a single month is not sufficient because holidays, days of
the week, first and last days of the month figure in for different
record creation algorithms.

But I can't get past this one test. How do I stop rspec from clearing
the relevant table before the test? I watch the records I want being
created, but then the db is restored to just the fixtures.

Note that I could have done this in shell in about 1/2 day but I've been
ordered to do this in the rspec framework. I feel like I'm building a
blivet here (10 pounds of ... slop in a 5-lb bag).

Please someone help? Otherwise I will just have to write the shell
script and call it from rspec :(
TIA

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

Ruby on Rails

Hi,

I am updating a record using activeresource object. I get an error "cant
mass assign protected attributes id, created_at , updated_at". This is
because i read a record, modify some values and then update the entry
using object.save( which also updates id, created_at etc). To remove
this error i can include the id, created_at fields in the model file.
But is there a better way to get out of this prob?

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

Ruby on Rails

Environment: Rails 3.2.3

This is my first attempt at doing a dropdown menu in a Rails
application. I tried looking for help on the topic, but what complicated
things is that the term dropdown menu is used for actual dropdown menu
(page menu), as well as what is dropdown lists, form options, form
selections, etc.

I found a pointer to https://github.com/dkeskar/rails-jquery-dropdown,
and following the instructions, I downloaded jquery_dropdown_helper.rb:
) and placed it in /lib

In my Gemfile, I have the following:

gem 'jquery-rails'

I downloaded jquery_dropdown_helper.rb:
https://github.com/dkeskar/rails-jquery-dropdown) and placed it in /lib

In _header.html.erb, I have the following:

<% require 'jquery_dropdown_helper' %>
....
<%= hidden_field_tag :sort_criteria %>
<%= dropdown_tags :sort_criteria, 'Select Criteria',
%w(Category Status Amount-High Amount-Low) %>

Here's the error code I'm getting:

undefined method `gsub' for :sort_criteria:Symbol

Any ideas?

Attached is the jquery_dropdown_helper.rb

Attachments:
http://www.ruby-forum.com/attachment/7541/jquery_dropdown_helper.rb


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

Ruby on Rails

Thanks alot for the pointer :)

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

Ruby on Rails

Say I have a Dog that has_may legs (In this case we don't care how many).  In the _form for Dog, I would like to assign a pre-existing let to him.  I would like to do something like this:

<%= f.collection_select :leg_1, Leg.select { |l| l.dog_id == nil }, :id, :description %>
<%= f.collection_select :leg_2, Leg.select { |l| l.dog_id == nil }, :id, :description %>

Then in my controller's create action:

@dog = Dog.new(params[:dog])
@dog.save
leg = Leg.find(params[:leg_1])
leg.dog = @dog
leg.save

The problem is that the collection_select is trying to set the leg_1 value as part of Dog, which of course does not exist. Do I need to create 'view model' for doing this?

Thanks,
~S

--
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/-/L0hQFvIaEFgJ.
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-US.

Ruby on Rails

Looking for a Ruby on Rails developer to add to our team. We are
creating an innovative ecommerce solution that will change the way
people buy and sell products online. We have a clear revenue plan,
scalable business model, and interested VCs. Looking for developers
that are looking to work on an early-stage, world-changing project.

Responsibilities:
Design, architect, implement, and QA web applications

Preferred Skills/Experience:
-Ruby on Rails
-MySQL Database
-jQuery/Javascript
-HTML/CSS
-Amazon AWS
-Browser Plugin Development
-Web API Experience
-Linux Administration

Ideally:
-Experienced in developing, releasing, and supporting web
applications.
-Self-motivated and excellent problem solver.
-Trustworthy, proactive, responsible and a team player.
-A sense of humor.

We completely understand if you currently have a full-time job, as
most of our team is working on this part-time. However, we really need
a strong developer who is willing to work independently with a small
team in a rapid environment.

Compensation: Generous equity stake/Possible monetary compensation
Location: Remote/USA

Please submit the following to alex@cosmiccart.com with the
following...
-A copy of resume that indicates relevant projects/experience.
-Links to relevant past projects/code samples.

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

Ruby on Rails

On Jun 28, 1:03 pm, Michael Baldock <li...@ruby-forum.com> wrote:
> Hi, I get constantly nervy whenever trying to implement any javascript /
> jquery in rails, basically because I'm not sure where to put things in
> the project!
>
> I know the people at rails have thought long and hard about how to best
> structure an app, so I'd like to learn the correct way.
>
> I'm using rails 3.2, ruby 1.9.3
>
> /////////////
> 1st situation - using a gem to include a javascript package :
>
> By default now I notice  this is included in the gemfile : gem
> 'jquery-rails'
>
> there's also these lines in application.js
> //= require jquery
> //= require jquery_ujs
>
> and there's this in my layout view
>
> <%= javascript_include_tag "application" %>
>
> do I have to do anything at all to use jQuery in my application?
> If I want to use some jQuery on a page, where's the place to put it? in
> the controller.js.coffee? Or on the page between <script> and </script>
> can I use js / jquery in this strange .coffee file?

coffeescript compiles to javascript. If you don't want to use coffee
script (I'd give it a go if I were you) rename controller.js.coffee to
just controller.js.
Be aware that (by default at least) all of those js files will be
loaded together, so make sure the code you write there won't interfere
with pages it's not supposed to act on (it's up to you to come up with
something to handle this)
>
> //////////////
> 2nd situation - now I want to use JQUery-UI
>
> What is the best way to use jQuery UI, and where should I put it.
>
> I downloaded the minimised version from jQuery website, but which folder
> do I put it in? public/...?
> What am I meant to add to application.js?
> and do I need to add anything extra to the layout?
>
> //////////
> 3rd Situation - now I want to use the jQuery-ui CSS to make it look nice
>

I use the gem 'jquery-ui-rails' for the last 2. As you might imagine
it vendors jquery ui but it splits it up so that you only load the
components you need, i.e. you can stick in your application.js

//= require jquery.ui.tabs

and it will only load that bit (it knows about dependencies and will
pull in whatever bits of jquery-ui are needed to make ui.tabs work.
This gem does the same for stylesheets too, you can add

/*
*= require jquery.ui.tabs
*= require jquery.ui.slider
*/

to your css manifest to only include those bits.

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

Ruby on Rails

On Jun 29, 4:25 am, Tom Choi <li...@ruby-forum.com> wrote:
> Hello,
>
> I know in ruby that when you want to find the size of your query say
>
> [1,2,3,4,5,6] would provide 6 as the total size, length, or even count.
>
> When I try to use size, length, or count on my application, I would get
> a pretty darn slow performance (takes around 10 seconds to load each
> count and I do it twice). Is there another faster way to get the total
> size from the postgres query?

on an active record scope (which includes associations)

- length will always force all the results to be loaded and then the
length of the array is returned
- count will do a select count(*)
- size will either use the length of the array if it is loaded or do a
count(*) if not

So using length if you don't actually want all the objects loaded will
be way slower.

if a simple count is that slow then you probably want to look at your
database indexes - use explain from the psql console to find out how
it is running your query (on rails 3.2 active record will do this for
you if you've turned on auto explains)

Fred


>
> I am using this kind of format in database
>
> e.g: table population [id, race id]
>      table race [id, persons id]
>      table persons[id, likes]
>
> so if I use "population.race.persons.count" I would get the total size
> of the persons in that particular race and population.
>
> --
> 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-US.

Ruby on Rails

On Jun 28, 2012, at 9:38 PM, narayana perla wrote:

> Hi,
>
> I have a scenario where a row in a DB can be updated by multiple
> activeresource clients. Is there a way to lock a row in active resource ?

Have you read this? http://www.engineyard.com/blog/2011/a-guide-to-optimistic-locking/

Walter

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

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

Ruby on Rails

This might not be what you're looking for but I'd start by reading up on the Asset Pipeline. Then there are useful railscasts on both subjects.

On Thursday, June 28, 2012 8:03:40 AM UTC-4, Ruby-Forum.com User wrote:

Hi, I get constantly nervy whenever trying to implement any javascript /
jquery in rails, basically because I'm not sure where to put things in
the project!

I know the people at rails have thought long and hard about how to best
structure an app, so I'd like to learn the correct way.

I'm using rails 3.2, ruby 1.9.3

/////////////
1st situation - using a gem to include a javascript package :

By default now I notice  this is included in the gemfile : gem
'jquery-rails'

there's also these lines in application.js
//= require jquery
//= require jquery_ujs

and there's this in my layout view

<%= javascript_include_tag "application" %>

do I have to do anything at all to use jQuery in my application?
If I want to use some jQuery on a page, where's the place to put it? in
the controller.js.coffee? Or on the page between <script> and </script>
can I use js / jquery in this strange .coffee file?

//////////////
2nd situation - now I want to use JQUery-UI

What is the best way to use jQuery UI, and where should I put it.

I downloaded the minimised version from jQuery website, but which folder
do I put it in? public/...?
What am I meant to add to application.js?
and do I need to add anything extra to the layout?


//////////
3rd Situation - now I want to use the jQuery-ui CSS to make it look nice

Do I link to the online page at
http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/base/jquery-ui.css
in my layout, pulling in the css dynamically
or copy and paste that to a file and include it in the project?
if I include this in the project where do I put it?
Do I need to add anything to application.css, and or my layout?


That's enough for now! I know these questions might seem a bit
pointless, but I want to know the right way to do this. I had an app
looking and functioning perfectly on my local system, but then when I
uploaded it to heroku all jquery-ui stuff and some of the css didn't
work, even after a 'rake assets:precompile' I've now got a project with
lots of extra includes, and js / css files repeated in different places
just to get it to work on heroku.

Very annoying, and I'm sure if I just knew the right way to organise
everything it'd be much easier.

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 view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/4imuFJ-xuKkJ.
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-US.

Ruby on Rails

Perception 1:

I'm not sure but according to the Sql Query that you put here it seems that there's a table in your application database called
"campaign_sites" not "sites" (or maybe you have another table sites which can't be perceived from this report here or you're doing
kind of an aliasing or something!) and if you wanted to order by the name of a campaign site I think you should change
the "sites.name" to "campaign_sites.name"

Because this query seems straightforward you joined the campaign and campaign_site on the campaign_id (according to your has_many|belongs_to association)
and then you want the result to be ordered by campaign_site's name I guess.

Perception 2:
The other perception here form the Sql Query and more specifically the part -> "campaign_sites.site_id = 11377" is that site_id is a foreign key to a sites table
in your campaign_sites table and if that's the case because you didn't include the "sites" table in your JOIN mechanism then it can't find sites.name cause
there is no sites in the query join result from your tables. (you only have tables -> campaigns and campaign_sites in the JOIN)

Hope that helps. But I think a little more explanation about your model relationships (campaign, campaign_sites, [sites if there's such a thing]) can be helpful so we can understand the problem better and maybe
give you better answers.

Good Luck ;)

--
Sam Serpoosh
Software Developer: http://masihjesus.wordpress.com
Twitter @masihjesus

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

Ruby on Rails

Hi Colin Law
it's very good explanation!

thank very much !!!

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

Ruby on Rails

Hi all,

           Recently i am upgrading one of my rails app to 3.2.6. It seems the dafault_scope with options has been deprecated.
i have a scope like this default_scope :include => [:campaign, :site], :order => :'sites.name' in a relational model campaign_site
 which giving this error 

Mysql2::Error: Unknown column 'sites.name' in 'order clause': SELECT `campaigns`.* FROM `campaigns` INNER JOIN `campaign_sites` ON `campaigns`.`id` = `campaign_sites`.`campaign_id` WHERE `campaign_sites`.`site_id` = 11377 ORDER BY campaigns.name, sites.name
Any idea how to get around this?
Thanks 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/-/zdecvl86inwJ.
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-US.

Ruby on Rails

On 29 June 2012 09:42, Gurdipe Dosanjh <rhomobileapps@gmail.com> wrote:
> Hi
>
> I am working in a linux ruby rails environment and would like to install
> some gems but ensure that i they only work within my branch of the code and
> are not put into the gem path so that they are visible to everyone else

Use rvm, then each user and rails app can have a different set of gems
https://rvm.io

In fact it is highly recommended to use rvm anyway.

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

Ruby on Rails

Hi


I am working in a linux ruby rails environment and would like to install some gems but ensure that i they only work within my branch of the code and are not put into the gem path so that they are visible to everyone else

How can I do this?

my current gem env is

[ta84@ukird135 ~/projects/RB-3.7-dev01]$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.6
  - RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]
  - INSTALLATION DIRECTORY: /appl/apache/dev/development/ruby/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /appl/apache/dev/development/ruby/bin/ruby
  - EXECUTABLE DIRECTORY: /appl/apache/dev/development/ruby/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /appl/apache/dev/development/ruby/lib/ruby/gems/1.8
     - /home/ta84/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/
[ta84@ukird135 ~/projects/RB-3.7-dev01]$


Gurdipe

--
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/-/qh6Uhz9SqlQJ.
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-US.

Ruby on Rails

Hi Paul,

I read your post this morning as I'm setting out to achieve exactly the
same objective - updating Shopify with inventory levels from a remote
XML (wholesale) feed.

I've got a ROR Shopify app up and running so am set with the
authentication side.

Would be really keen to hear how you got on with your project and
whether you'd be able to offer any advice.

Many thanks,
David

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

Ruby on Rails

hi


I am trying to update the following method as the retry we have hard coded to ensure the sql transaction retires three times does not work.

When we get a failure it rolls back but does not retry.

Is there another I can add a retry or correct the following code

Gurdipe

    def export_data( table_nickname, output_data_file, column_headers )
      component,table_nickname = get_component(table_nickname)
      data_warehouse_class = component.class
      data_warehouse_instance = data_warehouse_class.instance
      # Get table name
      teradata_table_name = data_warehouse_instance.send(table_nickname).to_s
      start_time = Time.now()
      # Create column list, with various casting and reformatting
      column_list = []
      column_headers.each do |column_header|
        format = ""
        if column_header.type == 'DA'
          format = "(format 'YYYY/MM/DD')"
        end
          
        column_def = "CAST( COALESCE( TRIM( #{column_header.name} #{format} ) , '') as VARCHAR(#{column_header.max_length+10}) )" # Some data types need extra space so add 10 chars
        column_list.push(column_def)
      end
      tries = 3 # try three times and then give up
      begin
      # Create fastexport definition
      fed = <<END_FED
  .logtable DXWI_PROD_CRORDER_PLAY_PEN.promo_fexp_#{Time.now.strftime("%Y%m%d%H%M%S")}_log;
  .logon tdpm/#{DATA_WAREHOUSE_CONFIG['username']},#{DATA_WAREHOUSE_CONFIG['password']};
  .begin export sessions 10;

  .export outfile #{output_data_file}
    format fastload 
    mode record;

  /* FETCH DATA */
  SELECT
  #{column_list.join(" ,\n")}
  FROM #{teradata_table_name}
  ;

  /* END */
  .end export;

  /* LOGOFF */
  .logoff;

  /* DONE */
END_FED

      # Write definition to a temporary file, because calling it from a ruby pipe can cause blocks
      # on tables with lots of columns (denorm_brag_report)
      fed_file = "#{GENERAL_SYSTEM_SETTINGS['fastexport_temp_dir']}/#{teradata_table_name.downcase}_data.fed"
      File.open(fed_file, 'w') {|f| f.write(fed) }

      RAILS_DEFAULT_LOGGER.info("FLA_FILE_PATH: <#{output_data_file}>")
      RAILS_DEFAULT_LOGGER.info("TERADATA_TABLE: <#{teradata_table_name}>")
      RAILS_DEFAULT_LOGGER.info("Fastexport Definition File:\n #{fed_file}\n")
      RAILS_DEFAULT_LOGGER.info("Fastexport Definition:\n #{fed}\n")

      # Use fexp (fastexport) as system command
      RAILS_DEFAULT_LOGGER.info("Executing fastexport")
      
        output = nil
        open_return = IO.popen("fexp < #{fed_file}", "w+") do |pipe|
          pipe.close_write()
          output = pipe.read()
        end
      rescue
        tries -= 1
        sleep(1) # since we sometime get a time stamp problem, wait one second and then retry
        retry if tries > 0 
        raise # re-raise the exception if it hasn't been retried
      end        
      # Check results
      result = $?
      if result == 0
        RAILS_DEFAULT_LOGGER.info("--")
        RAILS_DEFAULT_LOGGER.info("Finished Extracting data from Teradata (#{Time.now()-start_time} seconds)")
        RAILS_DEFAULT_LOGGER.info("--")
      else
        RAILS_DEFAULT_LOGGER.info("Failed Extracting data from Teradata (#{Time.now()-start_time} seconds) - Error code: #{result}")
        RAILS_DEFAULT_LOGGER.info("Output from FastExport:\n#{output}")
        raise("ERROR: Export of Table <#{teradata_table_name}> failed - Error Code  #{result}.")
      end
      return
    end

--
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/-/G3xDSOMpEq0J.
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-US.

Ruby on Rails

On 29 June 2012 03:03, kengsreng tang <lists@ruby-forum.com> wrote:
> For example:
> i have model Person
> Class Person
>  id: 1
>  name: "test"
> end
>
> this code:
> Person.name_will_change!
>
> why we need to put that above line of code?

I think these probably cover it.

http://railscasts.com/episodes/109-tracking-attribute-changes/
http://archives.ryandaigle.com/articles/2008/3/31/what-s-new-in-edge-rails-dirty-object

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