Ruby on Rails Monday, June 30, 2014


I observed there is a typo in command, it should be : 

bundle exec whenever --update-crontab --set environment=production. 

Trying again with this command. 

Thanks. 

--
Regards,
Ankur 

On Mon, Jun 30, 2014 at 1:35 PM, Ankur Kumar <specialankur@gmail.com> wrote:

I am using whenever gem and I defined 'whenever crontab execution' command in .ebextensions folder for AWS EC2 instance. 

-RAILS_ROOT/.ebextensions/whenever_task.config

container_commands:
 20whenever_task:
   command: bundle exec rake whenever --update-crontab --set environment=production
   leader_only: true

The deployment on AWS fails because of following error:

-EC2_ROOT/var/log/eb-tools.log

2014-06-30 00:42:46,257 [INFO] (22990 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Script succeeded.
2014-06-30 00:43:58,172 [INFO] (22944 MainThread) [command.py-130] [root command execute] Command returned: (code: 1, stdout: Error occurred during build: Command 20whenever_task failed
, stderr: None)
2014-06-30 00:43:58,174 [DEBUG] (22944 MainThread) [commandWrapper.py-60] [root commandWrapper main] Command result: {'status': 'FAILURE', 'results': [{'status': 'FAILURE', 'config_sets': ['Infra-WriteRuntimeConfig', 'Infra-WriteApplication1', 'Infra-WriteApplication2', 'Infra-EmbeddedPreBuild', 'Hook-PreAppDeploy', 'Infra-EmbeddedPostBuild', 'Hook-EnactAppDeploy', 'Hook-PostAppDeploy'], 'returncode': 1, 'events': [], 'msg': 'Error occurred during build: Command 20whenever_task failed\n'}], 'api_version': '1.0'}

Any help on this?

--
Regards,
Ankur

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CALSL1ePpWLkO-mCNKu9JyxNhuULc4RPAbV9w8nb6zu0gfv2ynw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I'm using Ransack and will_paginate on an Oracle view to fetch records to generate an array of hashes for DataTables.

@users = User.search(params[:q]).result.page(params[:page]).per_page(params[:per_page])

There's no primary key so my display currently looks like:

John | Doe | 123
-----------------------
John | Doe | 456
-----------------------
Jane | Doe | 123
-----------------------

Ideally, I'd like to be display it like this:


John | Doe | 123, 456
------------------------------
Jane | Doe | 123
------------------------------

I'm curious how people would go about doing this.

Can I use distinct on the Ransack result, paginate it to reduce my record set, do a left join on User to get the rows removed by distinct... and then what?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1f06e8b7-e134-463e-a11b-64dee7d2facc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi All,

I'm looking for strong support in CSS/HAML/RAILS/SAAS. 


Need some PSD's broken down - have some excellent creative work done and custom fonts. 

- Should understand ruby on rails asset pipeline and if possible help with integration into current site. 
- Should enjoy HAML
- Should develop with a modular approach for a code base that is clean
- Must understand mobile design


This will most likely work into a long term engagement for the right consultant.

If interested please email me for further details @ anthony@getsortbox.com or Skype me @ wudukes

Included in the email should be your favorite dessert or beer and some examples of your work. 

Thank You :L)

Tony

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/18507b69-f121-4484-a635-30b5bb223706%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Oops, I meant Foo.all.each {|foo| foo.bar } for the second one.

--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/867980a6f28475cdebae5e7e377d65ff%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

If I have a method "bar" on a model "Foo", this should not work right?

Foo.all.bar

Should be this?

Foo.all.each {|foo| Foo.bar }

--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/da8b70545d974693008db4f26cedd875%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



Server admin in snow leopard is now server.app in Mavericks?

Liying

On Saturday, June 28, 2014 8:41:11 AM UTC-4, Jim wrote:

I followed your advice, still couldn't get my site running. Do you set up your rails project in
Mac OSX Mavericks? It seems from its instruction, /etc/apache2/httpd.conf is
/Library/Server/Web/Config/apache2/httpd_server_app.conf 

Are you using Server.app?  If so, then things are somewhat different.  In fact, looking back at your original message I see you mentioned a Server-specific path.  

You would want to put your passenger.conf file in /Library/Server/Web/Config/apache2/other/.  

You can still edit your /etc/hosts file to include a local domain for your project, which will make things easier.  You would then set up a new website in Server.app, using the domain you set up /etc/hosts for your project, and tell it site files are stored in the public folder of your rails project.  I use RVM, so I have to edit the config file Server.app generates to add

PassengerRuby /usr/local/rvm/gems/ruby-2.1.2@my_gemset/wrappers/ruby

You can run this command from your rails project directory to see what you should be using for PassengerRuby:

passenger-config --ruby-command

If you want to run your rails app in development mode, you'll also need to add 

    RackEnv development

to your site config file.  Your site config file will be in:

/Library/Server/Web/Config/apache2/sites/

and will be named something like:

0000_any_80_my.project.domain.conf

Your passenger installation doesn't necessarily need to be done via rbenv, it will be just fine installed with the system ruby.  However, you will need the PassengerRuby directive so it knows where to find the ruby and gem set to use when it instantiates your project.

Jim

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a54c08c8-2636-4a90-825e-1342c3d744ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails


Dear Jm:

Thanks a lot for your reply!

Yes, server.app comes with Mavericks, so I use it to host Rails web apps and have tried to create
passenger.conf under other folder etc. I set up everything in snow leopard under directory "/etc/apache2",
and sites folder was also inside /etc/apache2, it is quite straightfoward and easy, but when I try
to do the samething with server.app under folder /Library/Server/Web/Config/apache2. I couldn't
make it work, the steps seem to be quite simple, but not easy to find out what might go wrong.

I used brew to install passenger.

Liz


On Saturday, June 28, 2014 8:41:11 AM UTC-4, Jim wrote:

I followed your advice, still couldn't get my site running. Do you set up your rails project in
Mac OSX Mavericks? It seems from its instruction, /etc/apache2/httpd.conf is
/Library/Server/Web/Config/apache2/httpd_server_app.conf 

Are you using Server.app?  If so, then things are somewhat different.  In fact, looking back at your original message I see you mentioned a Server-specific path.  

You would want to put your passenger.conf file in /Library/Server/Web/Config/apache2/other/.  

You can still edit your /etc/hosts file to include a local domain for your project, which will make things easier.  You would then set up a new website in Server.app, using the domain you set up /etc/hosts for your project, and tell it site files are stored in the public folder of your rails project.  I use RVM, so I have to edit the config file Server.app generates to add

PassengerRuby /usr/local/rvm/gems/ruby-2.1.2@my_gemset/wrappers/ruby

You can run this command from your rails project directory to see what you should be using for PassengerRuby:

passenger-config --ruby-command

If you want to run your rails app in development mode, you'll also need to add 

    RackEnv development

to your site config file.  Your site config file will be in:

/Library/Server/Web/Config/apache2/sites/

and will be named something like:

0000_any_80_my.project.domain.conf

Your passenger installation doesn't necessarily need to be done via rbenv, it will be just fine installed with the system ruby.  However, you will need the PassengerRuby directive so it knows where to find the ruby and gem set to use when it instantiates your project.

Jim

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/59b7f0a5-2660-4615-809c-040abe686e94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 30 June 2014 19:37, Fresh Mix <lists@ruby-forum.com> wrote:
> After two hours of trying I can't get sorting to work :(

Well if you showed us your best try and tell us what did not work then
we may be able to help.

But I would really much rather you first worked right through the
tutorial I suggested, and also read and understand all the Rails
Guides.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvM8Oy4s4uti5UtW8gY1wOimZGkp2CK03qp8xBpk7hvhA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

After two hours of trying I can't get sorting to work :(

--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/82dd5d11d6324aa1fb3dcbcd33a3f986%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hello All,

As i am new to ROR and i am searching a job. can anyone please help me to crack technical question that can be asked during interview?

Any blog or website link will be helpful.

Best,
Sumit

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CABNVG36%3DAxVvxzqTDTL2%3DDTFkJpuDOigdhQVpN0OCe3XfcAhVA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Thanks,

The last one is what I needed.
Now I have to figure out how I can use this in a cucumber scenario.

Roelof


Op maandag 30 juni 2014 17:49:03 UTC+2 schreef Colin Law:
On 30 June 2014 16:19, Roelof Wobben <rwo...@hotmail.com> wrote:
> Hello,
>
> Suppose I have this model :
>
> class Member < ActiveRecord::Base
> end
>
> Now I have this controller :
>
> class MemberController < ApplicationController
>   def new
>      @member = member
>   end
> end
>
> and this form :
>
> <h1>Add a new member</h1>
> <%= form_for @member do |form| %>
>
>   <p>
>     <%= form.label :name, "Name: " %>
>     <%= form.text_field :name %>
>   </p>
>
>   <p class='buttons'>
>     <%= form.submit "Shorten my URL" %>
>   </p>
>
> <% end %>
>
>
> Now I have filled in the form the name "roelof"
>
> How can I later check if there is a member with the name "roelof"
> or can I do @member.name = "roelof"

To test if a particular member (in @member) has that name then you
would have to use
if @member.name == "reolof"

But if you mean after you have saved it to the database you want to
know if there is a member with that name then you can see if
Member.where(name: 'Reolof'')
returns any records.

Or is that not what you mean?

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e5355351-fe43-491b-b68a-9b10281c791e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 30 June 2014 16:19, Roelof Wobben <rwobben@hotmail.com> wrote:
> Hello,
>
> Suppose I have this model :
>
> class Member < ActiveRecord::Base
> end
>
> Now I have this controller :
>
> class MemberController < ApplicationController
> def new
> @member = member
> end
> end
>
> and this form :
>
> <h1>Add a new member</h1>
> <%= form_for @member do |form| %>
>
> <p>
> <%= form.label :name, "Name: " %>
> <%= form.text_field :name %>
> </p>
>
> <p class='buttons'>
> <%= form.submit "Shorten my URL" %>
> </p>
>
> <% end %>
>
>
> Now I have filled in the form the name "roelof"
>
> How can I later check if there is a member with the name "roelof"
> or can I do @member.name = "roelof"

To test if a particular member (in @member) has that name then you
would have to use
if @member.name == "reolof"

But if you mean after you have saved it to the database you want to
know if there is a member with that name then you can see if
Member.where(name: 'Reolof'')
returns any records.

Or is that not what you mean?

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLv1ThGxwSDWjCcFHLUqDOkUAi0%3Da60F9HW0m5EqVRT59Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hello,

Suppose I have this model :

class Member < ActiveRecord::Base
end

Now I have this controller :

class MemberController < ApplicationController
  def new
     @member = member
  end
end

and this form :

<h1>Add a new member</h1>
<%= form_for @member do |form| %>
 
  <p>
    <%= form.label :name, "Name: " %>
    <%= form.text_field :name %>
  </p>
 
  <p class='buttons'>
    <%= form.submit "Shorten my URL" %>
  </p>
 
<% end %>


Now I have filled in the form the name "roelof"

How can I later check if there is a member with the name "roelof"
or can I do @member.name = "roelof"

Roelof


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d8fb9db1-8935-46a2-b6f3-c1bf0adff4c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 30 June 2014 15:11, Fresh Mix <lists@ruby-forum.com> wrote:
> Colin Law wrote in post #1151137:
>
> Ok. But is it possible to sort Pages by visits.count? I can't find it
> tutorial...
>
> An sorting by likes is even more difficult?

You can sort by anything you like, in plain ruby if you can't see how
to use order when fetching it from the database.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLv7fXPR0inQcV%2B3bRqgfSBXV42%2BiZV-ZhTiH7QB3EzJHg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 30 June 2014 14:45, Jaimin Pandya <lists@ruby-forum.com> wrote:
> What is a difference between belongs_to and has_one?

They are at opposite ends of the association. The model that
belongs_to is the one that has the Y_id field in the database.

>
> How can I decide belongs_to use to X(assume) model and has_one use to
> Y(assume) model?

Do you mean how to decide whether X belongs_to Y and Y has_one X
versus Y belongs_to X and X has_one Y? If so then it is just a matter
of which seems to fit best for you. Of course a third alternative is
to simplify the code and the database and combine the models into XY.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLuEfV%2B1ehaN6PEp3KbNL066QHZJh1_JyFUHzJaxCVLbMQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Colin Law wrote in post #1151137:

Ok. But is it possible to sort Pages by visits.count? I can't find it
tutorial...

An sorting by likes is even more difficult?

--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3aeb30f59fe6995e5d0c6f921c1ca272%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi

Does Ruby on Rails support sha1 as hash algorithm in digest access authentication?
In case it does, how do I configure the web server to use it?

Kind regards,
Federico.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/345aaf86-1cf0-4943-980c-0838873e1e12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

What is a difference between belongs_to and has_one?

How can I decide belongs_to use to X(assume) model and has_one use to
Y(assume) model?

Kind regards.

--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5d38e361d4f84b0638354b02d054534e%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 30 June 2014 09:57, Fresh Mix <lists@ruby-forum.com> wrote:
> Colin Law wrote in post #1151111:
>
>> If you iterate through the blogs then for each blog
>> visits_count = blog.visits.count
>
> Thanks, its works!
>
> But now I have added "liked" column to a visits-table:
>
> Visits (id, user_id, blog_id, page_id, liked)
>
> Default value is false but if user click "like"-link on a page its come
> to true.
>
> But how can I count all likes?
>
> page_likes_count = page.visits.liked.count Does not seem to work...

Think about it. page.visits is an activerecord association
(effectively an array) of visits. You can call count on that which
tells you how many in the array, but you can't call liked as that is a
member of a single Visit object. You can call where() on an
association however and then call count on that, so that is one way to
do it. How are you getting on with the tutorial? It would answer all
these basic questions for you so we do not need to use our time
helping you when you could help yourself.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsZMmhuer%2B%2BjQG9KCM6e6eoMdsqKFu-SUCMskfiHJaj%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Colin Law wrote in post #1151111:

> If you iterate through the blogs then for each blog
> visits_count = blog.visits.count

Thanks, its works!

But now I have added "liked" column to a visits-table:

Visits (id, user_id, blog_id, page_id, liked)

Default value is false but if user click "like"-link on a page its come
to true.

But how can I count all likes?

page_likes_count = page.visits.liked.count Does not seem to work...

--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c8008f0e34783e3a3481c37fab077f38%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails


I am using whenever gem and I defined 'whenever crontab execution' command in .ebextensions folder for AWS EC2 instance. 

-RAILS_ROOT/.ebextensions/whenever_task.config

container_commands:
 20whenever_task:
   command: bundle exec rake whenever --update-crontab --set environment=production
   leader_only: true

The deployment on AWS fails because of following error:

-EC2_ROOT/var/log/eb-tools.log

2014-06-30 00:42:46,257 [INFO] (22990 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Script succeeded.
2014-06-30 00:43:58,172 [INFO] (22944 MainThread) [command.py-130] [root command execute] Command returned: (code: 1, stdout: Error occurred during build: Command 20whenever_task failed
, stderr: None)
2014-06-30 00:43:58,174 [DEBUG] (22944 MainThread) [commandWrapper.py-60] [root commandWrapper main] Command result: {'status': 'FAILURE', 'results': [{'status': 'FAILURE', 'config_sets': ['Infra-WriteRuntimeConfig', 'Infra-WriteApplication1', 'Infra-WriteApplication2', 'Infra-EmbeddedPreBuild', 'Hook-PreAppDeploy', 'Infra-EmbeddedPostBuild', 'Hook-EnactAppDeploy', 'Hook-PostAppDeploy'], 'returncode': 1, 'events': [], 'msg': 'Error occurred during build: Command 20whenever_task failed\n'}], 'api_version': '1.0'}

Any help on this?

--
Regards,
Ankur

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CALSL1eMLMmw16J%3DjJuZmLutpz7Ni%2BktxPD0Me1w6Fb9mwfNMoQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 29 June 2014 22:26, Fresh Mix <lists@ruby-forum.com> wrote:
> Tables:
>
> Blogs (id, name)
> Users (id, name)
> Pages (id, title, data)
> Visits (id, user_id, blog_id, page_id)
>
> How many views every blog have?
> Result should be:: blog_id, blog_name, visits_count

If you iterate through the blogs then for each blog
visits_count = blog.visits.count
and obviously the id and name are blog.id and blog.name. However if
you find yourself using the id then you are probably not doing
something the best way, it is unusual to have to reference the id
directly.

>
> How many times each page has been accessed?
> Result should be: page_id, page_title, page_data, visits_count

If you understand the answer above then I am sure you can work this one out.

The fact that you have asked this suggests that you are a beginner at
rails, in which case I suggest you work right through a good tutorial
such as railstutorial.org (which is free to use online). Then you
should understand the basics of rails.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsgs-Gb8dNGyRcfh6YB75a0CpkZEz7GyRZ%2BdjpcY-prJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Sunday, June 29, 2014

Will the application be living on your hardware or your client's? If it's your hardware, I suppose there isn't much to it. Set up the server and retain root/admin access.

If you're in a situation where you must deploy on the client's hardware, I think your best bet is to establish a VM guest with your application. Set it up as if it were your own hardware (retain root/admin access) and configure the VM guest to talk to your client's network.

Your client will still have access to the machine, so if they wanted to invest the time they could probably get at your application (in both cases I would use FDE). In this case at least they have to put some effort into it.

On Friday, June 27, 2014 8:09:09 PM UTC-7, Sheyam Selvaraj wrote:
I am trying to implement my application in my client place and the application is developed in Ruby on Rails.

Since I am going to deploy on their premise I wish to make the code as encrypted can be compiled but not be able to view, use or copy.


How can I do that using open-source tools.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/51c188ba-3784-45e0-97b7-7b7bc88f757c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Tables:

Blogs (id, name)
Users (id, name)
Pages (id, title, data)
Visits (id, user_id, blog_id, page_id)

How many views every blog have?
Result should be:: blog_id, blog_name, visits_count

How many times each page has been accessed?
Result should be: page_id, page_title, page_data, visits_count

--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/581d838990b22ab8ae3abf8c0c4c69f7%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I tried the sudo fine / -name mod_passenger.so but it wouldn't find the file.

I don't think I have it for some reason. I'm very new to all this, so I'm not sure if I've provided enough information. I will be thankful for any and all help I can get, and please feel free to ask for more details if it's needed.

Thanks

On Friday, March 1, 2013 11:49:33 AM UTC-5, Jordon Bedwell wrote:
On Fri, Mar 1, 2013 at 10:46 AM, Vell <lovell....@gmail.com> wrote:
> I am trying to install passenger on a server that has apache installed from
> source. The install seemed to work fine but when I restart the httpd service
> I get the following error:
>
> Starting httpd: httpd: Syntax error on line 451 of
> /usr/local/apache2/conf/httpd.conf: Syntax error on line 1 of
> /usr/local/apache2/conf/extra/httpd-passenger.conf: Cannot load
> /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
> into server:
> /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/ext/apache2/mod_passenger.so:
> cannot open shared object file: No such file or directory

sudo find / -name mod_passenger.so
Change your so line to that file.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1e3f19c5-1670-4f3b-8c43-63350f8f50e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Sunday, June 29, 2014 1:19:42 PM UTC+1, Chris Butcher wrote:
> I've just started working on this again after some time off.
>
>
> In response to Fred's suggestion regarding input names, I looked into it and found you can specify custom input names in simple form like this:
>
>
>
>    <span class="impact-input">
>    <%= f.input :impact, required: false, :error => false, input_html: { class: 'form-control', :name => "impact[]" } %>
>    </span>
>    <span class="likelihood-input">
>    <%= f.input :likelihood, required: false, :error => false, input_html: { class: 'form-control', :name => "likelihood[]" } %>
>    </span>
>
>
> Note the ":name => " addition in the input_html attribute.
>
>
> Now this has not fixed the problem at all with regards to app behaviour. However the error message ("unpermitted parameters...")  in terminal has disappeared when I attempt to submit a risk:
>
>
>
>
>
> Started POST "/risks" for 127.0.0.1 at 2014-06-29 12:58:02 +0100
> Processing by RisksController#create as HTML
>   Parameters: {"utf8"=>"✓", "authenticity_token"=>"LOgpMvsEGkhQaoZX5BkrX+Nw1Ov9QQaHuQqWO+L8peI=", "risk"=>{"title"=>"aa", "description"=>"aadad", "area"=>"IT", "owner"=>"5", "action"=>"dadad", "date_of_action(3i)"=>"29", "date_of_action(2i)"=>"6", "date_of_action(1i)"=>"2014", "action_completed"=>"0"}, "impact"=>["4"], "likelihood"=>["4"], "commit"=>"Create Risk"}


You can see here that impact isn't inside the risk hash anymore - you need to set the parameter name to risk[impact][] (and similarly for likelihood).

It's normal that the parameter values are strings - the values from a form submit will always be strings. That shouldn't be a problem.

Fred
>
r.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e0ed3251-a4bb-494d-a403-e4d4d31ab5e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 29 June 2014 14:27, Fresh Mix <lists@ruby-forum.com> wrote:
> if @post.updated_at.strftime("%d-%m-%Y") !=
> Time.now.strftime("%d-%m-%Y")
>
> Or is there better way?

Those give you the dates in UTC, which may not be the same as the
local timezone date.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvG9M2qGqMKVX2mrwKv8e0tFQ2-5Q6qhqhXHXjbX5w6Og%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Read up on the Date class. You can compare dates directly, and you have the whole range of < = > operators to work on them.

Walter

On Jun 29, 2014, at 9:27 AM, Fresh Mix wrote:

> if @post.updated_at.strftime("%d-%m-%Y") !=
> Time.now.strftime("%d-%m-%Y")
>
> Or is there better way?
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/90923dbc34a739dd822264ed051931e1%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/D3F41B7D-D2CC-47CD-A703-2B106AE7BE6B%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

if @post.updated_at.strftime("%d-%m-%Y") !=
Time.now.strftime("%d-%m-%Y")

Or is there better way?

--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/90923dbc34a739dd822264ed051931e1%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

This is basic ruby...
--Rob
Sent from my phone...excuse any typos please!

On Jun 29, 2014 9:14 AM, "Fresh Mix" <lists@ruby-forum.com> wrote:
Colin Law wrote in post #1151057:

> The first question is what do you mean by today?  Note in particular
> that your date may not be the same as mine if we are in different
> timezones.


Same year, same month and same date. And I think that all of my visitors
are in the same time zone and it is not so important, about the same
day...

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/24e654426455cb49891c6893dad03b4f%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPncwvJySsckzGijkGzvT61cYcGWf1FfeoG9mFmaE_S86%3D%3DeCA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Colin Law wrote in post #1151057:

> The first question is what do you mean by today? Note in particular
> that your date may not be the same as mine if we are in different
> timezones.


Same year, same month and same date. And I think that all of my visitors
are in the same time zone and it is not so important, about the same
day...

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/24e654426455cb49891c6893dad03b4f%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 29 June 2014 13:41, Fresh Mix <lists@ruby-forum.com> wrote:
> How can you verify that it has not been updated today?

The first question is what do you mean by today? Note in particular
that your date may not be the same as mine if we are in different
timezones.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLs_VLqJH0dAXYet%3DASghNDo0Pd1xOs_RU%3DYV7dadp%2BoBQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Check if the current date is equal to that? 

--Rob
Sent from my phone...excuse any typos please!

On Jun 29, 2014 8:42 AM, "Fresh Mix" <lists@ruby-forum.com> wrote:
How can you verify that it has not been updated today?

if @post.updated_ad "is not today"
  @post.counter = @post.counter + 1
  @post.save
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e7f62059ee82c3da9a4cab0763412b40%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPncwvKO3VLh164RHQ9d3orod_2RRYf8EdsAt5yU%3D5d6fgftKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

How can you verify that it has not been updated today?

if @post.updated_ad "is not today"
@post.counter = @post.counter + 1
@post.save
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e7f62059ee82c3da9a4cab0763412b40%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I've just started working on this again after some time off.

In response to Fred's suggestion regarding input names, I looked into it and found you can specify custom input names in simple form like this:

   <span class="impact-input">
   <%= f.input :impact, required: false, :error => false, input_html: { class: 'form-control', :name => "impact[]" } %>
   </span>
   <span class="likelihood-input">
   <%= f.input :likelihood, required: false, :error => false, input_html: { class: 'form-control', :name => "likelihood[]" } %>
   </span>

Note the ":name => " addition in the input_html attribute.

Now this has not fixed the problem at all with regards to app behaviour. However the error message ("unpermitted parameters...")  in terminal has disappeared when I attempt to submit a risk:


Started POST "/risks" for 127.0.0.1 at 2014-06-29 12:58:02 +0100

Processing by RisksController#create as HTML

  Parameters: {"utf8"=>"✓", "authenticity_token"=>"LOgpMvsEGkhQaoZX5BkrX+Nw1Ov9QQaHuQqWO+L8peI=", "risk"=>{"title"=>"aa", "description"=>"aadad", "area"=>"IT", "owner"=>"5", "action"=>"dadad", "date_of_action(3i)"=>"29", "date_of_action(2i)"=>"6", "date_of_action(1i)"=>"2014", "action_completed"=>"0"}, "impact"=>["4"], "likelihood"=>["4"], "commit"=>"Create Risk"}

  User Load (0.4ms)  SELECT  "users".* FROM "users"  WHERE "users"."remember_token" = '1b3c0548b48b9f90cab54a695297436286ad0132' LIMIT 1

   (0.2ms)  BEGIN

  SQL (0.3ms)  INSERT INTO "risks" ("action", "area", "created_at", "date_of_action", "description", "owner", "title", "updated_at", "user_id") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING "id"  [["action", "dadad"], ["area", "IT"], ["created_at", "2014-06-29 11:58:02.816205"], ["date_of_action", "2014-06-29"], ["description", "aadad"], ["owner", "5"], ["title", "aa"], ["updated_at", "2014-06-29 11:58:02.816205"], ["user_id", 2]]

   (0.3ms)  COMMIT

Redirected to http://localhost:3000/

Completed 302 Found in 9ms (ActiveRecord: 1.2ms)


You can still see that the impact and likelihood fields are still omitted during the commit. Maybe this is because they are being passed in as strings (denoted by the quotes around the values you can see being passed in the terminal output above), even though the array is explicitly integer? I have tried forcing integers like this, but it has made no difference:


   <span class="impact-input">
   <%= f.input :impact, as: :integer, required: false, :error => false, input_html: { class: 'form-control', :name => "impact[]" } %>
   </span>
   <span class="likelihood-input">
   <%= f.input :likelihood, as: :integer, required: false, :error => false, input_html: { class: 'form-control', :name => "likelihood[]" } %>
   </span>

So I'm still stuck! If I change the input name like I have, would I have to adjust anything else in my application? This is my first rails project so forgive me if the answer to that is an obvious 'of course'.

Thank you both for your help thus far.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1023ecb8-2cc5-49a6-a3d6-7f10ccba20b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

've just started working on this again after some time off.

In response to Fred's suggestion regarding input names, I looked into it and found you can specify custom input names in simple form like this:

   <span class="impact-input">
   <%= f.input :impact, required: false, :error => false, input_html: { class: 'form-control', :name => "impact[]" } %>
   </span>
   <span class="likelihood-input">
   <%= f.input :likelihood, required: false, :error => false, input_html: { class: 'form-control', :name => "likelihood[]" } %>
   </span>

Note the ":name => " addition in the input_html attribute.

Now this has not fixed the problem at all with regards to app behaviour. However the error message ("unpermitted parameters...")  in terminal has disappeared when I attempt to submit a risk:


Started POST "/risks" for 127.0.0.1 at 2014-06-29 12:58:02 +0100

Processing by RisksController#create as HTML

  Parameters: {"utf8"=>"✓", "authenticity_token"=>"LOgpMvsEGkhQaoZX5BkrX+Nw1Ov9QQaHuQqWO+L8peI=", "risk"=>{"title"=>"aa", "description"=>"aadad", "area"=>"IT", "owner"=>"5", "action"=>"dadad", "date_of_action(3i)"=>"29", "date_of_action(2i)"=>"6", "date_of_action(1i)"=>"2014", "action_completed"=>"0"}, "impact"=>["4"], "likelihood"=>["4"], "commit"=>"Create Risk"}

  User Load (0.4ms)  SELECT  "users".* FROM "users"  WHERE "users"."remember_token" = '1b3c0548b48b9f90cab54a695297436286ad0132' LIMIT 1

   (0.2ms)  BEGIN

  SQL (0.3ms)  INSERT INTO "risks" ("action", "area", "created_at", "date_of_action", "description", "owner", "title", "updated_at", "user_id") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING "id"  [["action", "dadad"], ["area", "IT"], ["created_at", "2014-06-29 11:58:02.816205"], ["date_of_action", "2014-06-29"], ["description", "aadad"], ["owner", "5"], ["title", "aa"], ["updated_at", "2014-06-29 11:58:02.816205"], ["user_id", 2]]

   (0.3ms)  COMMIT

Redirected to http://localhost:3000/

Completed 302 Found in 9ms (ActiveRecord: 1.2ms)


You can still see that the impact and likelihood fields are still omitted during the commit. Maybe this is because they are being passed in as strings (denoted by the quotes around the values you can see being passed in the terminal output above), even though the array is explicitly integer? I have tried forcing integers like this, but it has made no difference:


   <span class="impact-input">

   <%= f.input :impact, as: :integer, required: false, :error => false, input_html: { class: 'form-control', :name => "impact[]" } %>

   </span>

   <span class="likelihood-input">

   <%= f.input :likelihood, as: :integer, required: false, :error => false, input_html: { class: 'form-control', :name => "likelihood[]" } %>

   </span>

So I'm still stuck! If I change the input name like I have, would I have to adjust anything else in my application? This is my first rails project so forgive me if the answer to that is an obvious 'of course'.

Thank you both for your help thus far.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b22d6d2d-4362-41b9-90f7-6e33faf17804%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I've just started working on this again after some time off.

In response to Fred's suggestion regarding input names, I looked into it and found you can specify custom input names in simple form like this:

   <span class="impact-input">
  <%= f.input :impact, required: false, :error => false, input_html: { class: 'form-control', :name => "impact[]" } %>
  </span>
  <span class="likelihood-input">
  <%= f.input :likelihood, required: false, :error => false, input_html: { class: 'form-control', :name => "likelihood[]" } %>
  </span>

Note the ":name => " addition in the input_html attribute.

Now this has not fixed the problem at all with regards to app behaviour. However the error message ("unpermitted parameters...")  in terminal has disappeared when I attempt to submit a risk:


Started POST "/risks" for 127.0.0.1 at 2014-06-29 12:58:02 +0100

Processing by RisksController#create as HTML

  Parameters: {"utf8"=>"✓", "authenticity_token"=>"LOgpMvsEGkhQaoZX5BkrX+Nw1Ov9QQaHuQqWO+L8peI=", "risk"=>{"title"=>"aa", "description"=>"aadad", "area"=>"IT", "owner"=>"5", "action"=>"dadad", "date_of_action(3i)"=>"29", "date_of_action(2i)"=>"6", "date_of_action(1i)"=>"2014", "action_completed"=>"0"}, "impact"=>["4"], "likelihood"=>["4"], "commit"=>"Create Risk"}

  User Load (0.4ms)  SELECT  "users".* FROM "users"  WHERE "users"."remember_token" = '1b3c0548b48b9f90cab54a695297436286ad0132' LIMIT 1

   (0.2ms)  BEGIN

  SQL (0.3ms)  INSERT INTO "risks" ("action", "area", "created_at", "date_of_action", "description", "owner", "title", "updated_at", "user_id") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING "id"  [["action", "dadad"], ["area", "IT"], ["created_at", "2014-06-29 11:58:02.816205"], ["date_of_action", "2014-06-29"], ["description", "aadad"], ["owner", "5"], ["title", "aa"], ["updated_at", "2014-06-29 11:58:02.816205"], ["user_id", 2]]

   (0.3ms)  COMMIT

Redirected to http://localhost:3000/

Completed 302 Found in 9ms (ActiveRecord: 1.2ms)


You can still see that the impact and likelihood fields are still omitted during the commit. Maybe this is because they are being passed in as strings (denoted by the quotes around the values you can see being passed in the terminal output above), even though the array is explicitly integer? I have tried forcing integers like this, but it has made no difference:


   <span class="impact-input">

  <%= f.input :impact, as: :integer, required: false, :error => false, input_html: { class: 'form-control', :name => "impact[]" } %>

  </span>

  <span class="likelihood-input">

  <%= f.input :likelihood, as: :integer, required: false, :error => false, input_html: { class: 'form-control', :name => "likelihood[]" } %>

  </span>

So I'm still stuck! If I change the input name like I have, would I have to adjust anything else in my application? This is my first rails project so forgive me if the answer to that is an obvious 'of course'.

Thank you both for your help thus far.



On Monday, June 23, 2014 10:12:04 PM UTC+1, Chris Butcher wrote:
I am having a bad time trying to get some form parameters (via a simple form, latest version), stored in an integer array in a PostgreSQL table. I have abstracted the key parts below, but if anyone would like to poke around, I have hosted the project on GitHub: https://github.com/cjbutcher/avc_risk_manager_2. Any help much appreciated, I have wrestled with this problem for days!

I am building a risk management app. A new risk should accept an integer from the 'impact' and 'likelihood' fields on the form view and insert them into arrays in the risk table. At the moment, all fields on the new/edit risk form update correctly, except impact and likelihood (the arrays). If I enter values in these fields, no error is thrown, yet they are not updated.

Here is the code for the form. I don't think the problem lies here, but here it is anyway:

app/views/shared/_risk_form.html.erb

<%= simple_form_for(@risk) do |f| %>
  <%= render 'shared/error_messages', object: f.object %>
  <div class="form-group">
    <%= f.input :title, required: false, :error => false, input_html: { class: 'form-control' } %>
  </div>

  <div class="form-group">
    <%= f.input :description, required: false, :error => false,  as: :text, input_html: { class: 'form-control description' } %>
  </div>

  <div class="form-group">
  <%= f.input :area, :collection => ['Operations', 'IT', 'Finance'], required: false, :error => false, input_html: { class: 'form-control' } %>
  </div>

  <div class="form-group">
  <%= f.input :owner, :collection => User.all, required: false, :error => false, input_html: { class: 'form-control' } %>
  </div>

  <div class="form-group">
  <%= f.input :action, required: false, :error => false, input_html: { class: 'form-control' } %>
  </div>

  <div class="form-inline">
  <span class="date-of-action-input">
  <%= f.input :date_of_action, as: :date, :start_year => Date.today.year - 10, :end_year => 2030,
  :order => [ :day, :month, :year], :required => false, :error => false, input_html: { class: 'form-control' } %>
 </span>
 <span class="action-completed-input">
 <%= f.input :action_completed, as: :boolean, required: false, :error => false, input_html: { class: 'form-control' } %>
    </span>

  <span class="impact-input">
  <%= f.input :impact, required: false, :error => false, input_html: { class: 'form-control' } %>
  </span>
  <span class="likelihood-input">
  <%= f.input :likelihood, required: false, :error => false, input_html: { class: 'form-control' } %>
  </span>
  <span class="submit-risk">
  <%= f.button :submit, :error => false, :error => false, input_html: { class: 'form-control' } %>
  </span>
  </div>
<% end %>

Here is the controller, note the strong params for impact and likelihood:

app/controllers/risk_controller.rb

class RisksController < ApplicationController
before_action :signed_in_user
before_action :correct_user, only: [:destroy, :update]


def create
@risk = current_user.risks.build(risk_params)
    if @risk.save
      flash[:success] = "Risk created!"
      redirect_to root_url
    else
      render 'new'
    end
end

def new
  @risk = Risk.new
end

def destroy
  @risk.destroy
  redirect_to root_url
end

def edit
  @risk = Risk.find(params[:id])
end

def update
  @risk = Risk.find(params[:id])
    @risk.assign_attributes(risk_params)
    if @risk.changed? == false
      flash[:info] = "No changes were made"
      redirect_to root_url
    elsif @risk.update_attributes(risk_params)
      flash[:success] = "The risk has been updated."
      redirect_to root_url
    else
        render 'new'
    end
end

private

def risk_params
params.require(:risk).permit(:description, :title, :area, :owner, :action, :date_of_action, :action_completed, { :impact => [] }, { :likelihood => [] })
end

  def correct_user
    if current_user.admin?
      @risk = Risk.find_by(id: params[:id])
      redirect_to root_url if @risk.nil?
    else
      @risk = current_user.risks.find_by(id: params[:id])
      redirect_to root_url if @risk.nil?
    end
  end

end

Here is the model. I purposefully left validations off the impact and likelihood fields for now so I don't have to worry about that being the problem:

app/models/risk.rb

class Risk < ActiveRecord::Base
belongs_to :user
validates :user_id, presence: true
validates :description, presence: true
validates :title, presence: true
validates :area, presence: true
validates :owner, presence: true
end

Finally, here is the db schema:

app/db/schema.rb

ActiveRecord::Schema.define(version: 20140622153923) do

  # These are extensions that must be enabled in order to support this database
  enable_extension "plpgsql"

  create_table "risks", force: true do |t|
    t.integer  "user_id"
    t.string   "description"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.string   "title"
    t.string   "area"
    t.string   "owner"
    t.string   "action"
    t.date     "date_of_action"
    t.boolean  "action_completed", default: false
    t.integer  "impact",           default: [],    array: true
    t.integer  "likelihood",       default: [],    array: true
  end

  add_index "risks", ["user_id", "created_at"], name: "index_risks_on_user_id_and_created_at", using: :btree

  create_table "users", force: true do |t|
    t.string   "name"
    t.string   "email"
    t.boolean  "admin",           default: false
    t.datetime "created_at"
    t.datetime "updated_at"
    t.string   "password_digest"
    t.string   "remember_token"
  end

  add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
  add_index "users", ["remember_token"], name: "index_users_on_remember_token", using: :btree

end

Any help much appreciated! If there is any extra information I can provide please let me know.

Thanks v much, Chris

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f2e56569-a889-4dd1-ab17-695178865738%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.