[Rails] Vulnerabililty with bootstrap-sass 3.2.0.3

2019-04-03 Thread Jim Ruther Nill
As outlined in
https://snyk.io/blog/malicious-remote-code-execution-backdoor-discovered-in-the-popular-bootstrap-sass-ruby-gem/

TLDR

If you use bootstrap-sass version 3.2.0.3, just do bundle update
bootstrap-sass and you're good to go

-- 
-
visit my blog at http://jimlabs.herokuapp.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+unsubscr...@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/CAJ8y7Vd3pVKeLtnmXvBbAWqSTfUz8c3wwL91eCN%2BCHpcnNFZGQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Why is id off by one or defined different in edit vs in update?

2018-06-08 Thread Jim Ruther Nill
On Sat, Jun 9, 2018 at 5:54 AM, Robert Phillips  wrote:

> why is id off by one or defined different in edit vs in update? I will
> explain what I mean
>
> I have a controller called Bottles and a model Bottle
>
> My config\routes.rb file has the line- resources :bottles
>
> I have this controller
>
> class BottlesController < ApplicationController
>   def index
>   end
>
>   def show
>   end
>
>   def edit
> # http://127.0.0.1:3000/bottles/0/edit   :id==0
>
> # "bottles",
> "action"=>"edit", "id"=>"0"} permitted: false>
>
> # Bottle.all[0] gives 
>
> @bottle=Bottle.all[params[:id].to_i]   #:id==0
>

Your error is on these lines.  When working on arrays, the first item in an
array has an index of 0.  So you'd think that

bottles = Bottle.all
bottles[0].id == 1
bottles[1].id == 2

and so on.

In the edit action, you should be getting the id of the bottle so you can
find the bottle using

Bottle.find(params[:id])


>   end
>
>
> I have these views
>
> C:\rubytest\testoby>type app\views\bottles\new.html.erb
> <%= form_for @bottle do |f| %>
> <%= f.text_field :name %>
> <%= f.text_field :size %>
> <%= f.submit “Create” %>
> <% end %>
>
> C:\rubytest\testoby>type app\views\bottles\edit.html.erb
> <%= form_for @bottle do |f| %>
> <%= f.text_field :name %>
> <%= f.text_field :size %>
> <%= f.submit “Save” %>
> <% end %>
> C:\rubytest\testoby>
>

For some weird reason, @bottle here should be defined in the edit action in
your controller.  But your
edit action is empty.


>
> I went to http://127.0.0.1:3000/bottles/new and I made a bottle
>
> name- tod
> size- 234
>
>
> I then go to http://127.0.0.1:3000/bottles/0/edit
>
Don't use the index as the number but the actual id saved in the database

> and I see the bottle there in the form
>
> I then change tod to todd and click ‘save’
>
>
> here’s the weird thing
>
>
> I see the URL change to
>
> http://127.0.0.1:3000/bottles/1
>
>
> but i’d expect it to change to
>
> http://127.0.0.1:3000/bottles/0
>
>
> I’d expect the form to be submitted to /bottles/0 but it’s not, it’s
> submitted to /bottles/1
>
>
> And the params have :id=1
>
>
> So when it comes to my update, I have to write this line in the
> controller, subtracting 1 from the id
>
>
> @abottle=Bottle.all[params[:id].to_i-1]
>
>
> I can see that there is a difference of definition of :id that one could
> use… The id in the URL could be either
>
> A)The index in the array e.g. Bottle.all[params[:id]] (Which is what i’ve
> got for the edit action). or
>
> B) The id attribute of the object, (Which is what i’ve got for the update
> action @abottle=Bottle.all[params[:id].to_i-1]
>
>
> One could say, it’s 'A', the URL. But then why should the update URL have
> an :id that is one up from the ID in the edit URL?
>
>
> Thanks
>
> --
> 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+unsubscr...@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/3e864d52-d02b-4aa4-9839-
> ba550b472fb0%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
visit my blog at http://jimlabs.herokuapp.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+unsubscr...@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/CAJ8y7Vcx6Kjaj6WZu16sN41JE6Tx3GYuaMT7pwWmW1jBz7RAeg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] override or add stylesheet to mounted engine pages

2018-02-26 Thread Jim Ruther Nill
On Tue, Feb 27, 2018 at 1:32 PM, fugee ohu  wrote:

> I mounted an engine and it has it's own assets pipeline How do I override
> or add to it? It's in a subdirectory under the gem root path
> /app/assets/stylesheets/blogit There's no application.css file in the
> folder, only other css files I created an application.html.erb file for the
> blog portion of the site so the file i need to add to the assets pipleline
> is application.css
>

CSS is loaded by order.  A more recently loaded stylesheet will override a
stylesheet loaded earlier.

= stylesheet_link_tag 'application'
= stylesheet_link_tag 'custom'

so in the code above, anything inside custom.css will take precedence over
those in application

> --
> 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+unsubscr...@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/a5aea9c5-f84c-469e-a6cc-
> cd287bce4e8d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
visit my blog at http://jimlabs.herokuapp.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+unsubscr...@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/CAJ8y7VdcShJ9jkhNyyvTKd8WOyf0AbWBY8C%3DfsLiGAHt2sKjNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Rspec =begin =end

2017-07-11 Thread Jim Ruther Nill
On Tue, Jul 11, 2017 at 9:27 PM, Ralph Shnelvar  wrote:

> In a file named spec/spec_helper.rb I see
> # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
> RSpec.configure do |config|
> # The settings below are suggested to provide a good initial experience
> # with RSpec, but feel free to customize to your heart's content.
> =begin
>   # These two settings work together to allow you to limit a spec run
>   # to individual examples or groups you care about by tagging them with
>   # `:focus` metadata. When nothing is tagged with `:focus`, all examples
>   # get run.
>   config.filter_run :focus
>   config.run_all_when_everything_filtered = true
>
>   .
>   .
>   .
>
>   # rspec-mocks config goes here. You can use an alternate test double
>   # library (such as bogus or mocha) by changing the `mock_with` option
> here.
>   config.mock_with :rspec do |mocks|
> # Enable only the newer, non-monkey-patching expect syntax.
> # For more details, see:
> #   - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-
> expectation-syntax/
> mocks.syntax = :expect
>
> # Prevents you from mocking or stubbing a method that does not exist
> on
> # a real object. This is generally recommended.
> mocks.verify_partial_doubles = true
>   end
>
> =end
> end
>
> What does the =begin/=end do?
>

it's a block comment.  Anything in between is commented.


>
> --
> 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+unsubscr...@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/42aebbd0-5b85-4390-a46b-
> 9f4961316257%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
visit my blog at http://jimlabs.herokuapp.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+unsubscr...@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/CAJ8y7VcuD6KFzWtpbVCxjS94f%3D_KrC9JWNMPWneyBaLyWsk14g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] div_for

2017-06-28 Thread Jim Ruther Nill
On Wed, Jun 28, 2017 at 1:38 PM, fugee ohu  wrote:

>
>
> On Tuesday, June 27, 2017 at 8:01:40 PM UTC-4, Walter Lee Davis wrote:
>>
>>
>> > On Jun 27, 2017, at 9:12 AM, fugee ohu  wrote:
>> >
>> >
>> >
>> > On Tuesday, June 27, 2017 at 7:32:33 AM UTC-4, Walter Lee Davis wrote:
>> >
>> > > On Jun 27, 2017, at 12:40 AM, fugee ohu  wrote:
>> > >
>> > >
>> > >
>> > > On Wednesday, June 21, 2017 at 8:34:17 AM UTC-4, Walter Lee Davis
>> wrote:
>> > >
>> > > > On Jun 21, 2017, at 3:52 AM, fugee ohu  wrote:
>> > > >
>> > > > How do I give new.js.erb the right element name
>> > > >$('#comment_post)click.(function(){
>> > > > In this line there's no id number
>> > >
>> > > I think you may have missed a few bits of my reply. We are not
>> observing a click any more. Everything is out of the jQuery pool, and fully
>> into the RJS pool. If you're viewing this in the Google Groups (Web) view,
>> you may need to expand all of the little ... ellipses in order to see all
>> of my threaded replies.
>> > >
>> > > in the second content_tag_for statement collection: post.comments
>> fails to produce anthing for comment.body when the _comment.html.erb
>> partial is rendered
>> > >
>> > > _post.erb.html
>> > >
>> > >  <%= content_tag_for(:div, post) do %>
>> > > <%= simple_format post.content %>
>> > > <% unless post.attachment.blank? %>
>> > >   <%= image_tag(post.attachment, height: 250) %>
>> > > <% end %>
>> > > <%= content_tag_for(:div, post, 'comments') do %>
>> > > <%= render '/comments/comment', collection: post.comments %>
>> > > <%= content_tag_for(:div, post, 'comment_form_holder') do %>
>> > > <%= link_to 'Comment', 
>> > > new_comment_path('comment[commentable_id]':
>> post.id, 'comment[commentable_type]': 'Post') %>
>> > > <% end %>
>> > > <% end %>
>> > > <% end %>
>> > >
>> > >
>> > > _comment.html.erb
>> > >
>> > > <%= content_tag_for(:div, @comments) do %>
>> > > <%= simple_format comment.body %>
>> > > <%= comment.post.user.first_name comment.post.user.last_name %>
>> > > <% end %>
>> >
>> >
>> > content_tag_for builds the DIV and gives it an ID based on a single
>> item passed to it. I'm not sure what it would make of a collection of
>> comments, which is what you're passing it here. What I think you need to do
>> is change @comments to comment, to match the rest of the local variables
>> inside the partial. @comments doesn't exist inside the partial unless you
>> render it in a scope that already had that set as an instance variable.
>> comment exists inside the partial because the partial is named comment, but
>> that's only true if you are either rendering it with the "shortcut"
>> collection: @comments, where @comments is an array or association of
>> individual comment instances, or are rendering it one at a time, and
>> passing in locals: { comment: @comment } or similar. Because you are
>> doubly-nested at this point, inside _post.html.erb, it is best to stick
>> with the local variables that you have passed along, and not rely on the
>> surrounding render context to magically provide variables for you.
>> >
>> > Try just changing @comments to comment in the first line of your
>> _comment.html.erb, leave everything else alone, and see if it renders then.
>> Just to be certain, check in the console whether you have any comments for
>> that post you are trying to render. You should not see anything at all (the
>> comment partial won't even render) if post.comments is empty.
>> >
>> > Walter
>> >
>> > I took out the div containers (content_tag_for) and just left:
>> > <%= simple_format comment.body %>
>> > <%= comment.post.user.first_name comment.post.user.last_name %>
>> > but I still get the error that comment is undefined
>>
>> Where are you calling render on this template? Copy and paste the code
>> here. Also copy and paste the error message so we can compare line numbers
>> from the error with line numbers in your code.
>>
>> Is the code that is quoted above exactly what you are using in your outer
>> post partial? What should be happening if you call render
>> 'comments/comment', collection: post.comments from inside the post.html.erb
>> partial is that each of the post comments will be rendered one after
>> another, and inside of each of those render calls, the instance variable
>> 'comment' will be loaded with the one comment that is being rendered. This
>> should Just Work™.
>>
>> Walter
>>
>> >
>> > --
>> > 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-ta...@googlegroups.com.
>> > To post to this group, send email to rubyonra...@googlegroups.com.
>> > To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/rubyonrails-talk/eea548b0-8979-4f0c-9662-9c720f5f35db%
>> 40googlegroups.com.
>> > For more options, visit https://groups.google.

Re: [Rails] passing parameters to delete link_to

2017-06-06 Thread Jim Ruther Nill
On Wed, Jun 7, 2017 at 11:24 AM, Jim Ruther Nill  wrote:

>
>
> On Wed, Jun 7, 2017 at 11:21 AM, fugee ohu  wrote:
>
>> The rails scaffolding generator creates delete links as objects in index
>> views so why when I google how to pass params to a delete link all the
>> answers are examples where a path is used My links don't have a path, they
>> have an object That's rails out of the box Like this:
>>
>><% @press_releases.each do |pr| %>
>>   
>> <%= link_to 'Edit', edit_press_release_path(pr) %>
>> <%= link_to 'Delete', pr, method: :delete, data: { confirm:
>> 'Are you sure?' } %>
>>
>> I didn't write the above code, rails generated it I tried using
>> delete_press_release_path but there was no such route available So how do I
>> pass an additional parameter in this link please Thanks in advance
>>
>
> just press_release_path(additional_params: true)
>

my bad. submitted immediately.

should be press_release_path(pr, additional_params: true)


>
> The reason why that goes to the destroy action is because of method:
> :delete
>
>> --
>> 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+unsubscr...@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/ms
>> gid/rubyonrails-talk/046f61e3-f8de-4adb-b33d-6fa39b519e4b%
>> 40googlegroups.com
>> <https://groups.google.com/d/msgid/rubyonrails-talk/046f61e3-f8de-4adb-b33d-6fa39b519e4b%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> -
> visit my blog at http://jimlabs.herokuapp.com
>



-- 
-
visit my blog at http://jimlabs.herokuapp.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+unsubscr...@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/CAJ8y7Vf2WHAADA4eeHP6vEwoD1ZsTJ%2B%2BphT1sUqiuuTt%3DjRBMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] passing parameters to delete link_to

2017-06-06 Thread Jim Ruther Nill
On Wed, Jun 7, 2017 at 11:21 AM, fugee ohu  wrote:

> The rails scaffolding generator creates delete links as objects in index
> views so why when I google how to pass params to a delete link all the
> answers are examples where a path is used My links don't have a path, they
> have an object That's rails out of the box Like this:
>
><% @press_releases.each do |pr| %>
>   
> <%= link_to 'Edit', edit_press_release_path(pr) %>
> <%= link_to 'Delete', pr, method: :delete, data: { confirm:
> 'Are you sure?' } %>
>
> I didn't write the above code, rails generated it I tried using
> delete_press_release_path but there was no such route available So how do I
> pass an additional parameter in this link please Thanks in advance
>

just press_release_path(additional_params: true)

The reason why that goes to the destroy action is because of method:
:delete

> --
> 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+unsubscr...@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/046f61e3-f8de-4adb-b33d-
> 6fa39b519e4b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
visit my blog at http://jimlabs.herokuapp.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+unsubscr...@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/CAJ8y7Ve88LGht5X6A8_okwPFG_CaK15uy34Bpuz6GeUBddpZ8Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Part time remote work

2017-04-30 Thread Jim Ruther Nill
Hi guys,

I'm posting another "looking for remote work" post as things have settled
down with
the last project.

If anyone is looking for a Rails developer with solid experience, just hit
me up and let's
talk.  I can commit around 4 hours a day as I have full time work.

Thanks a lot and have a great week ahead everyone!

-- 
-
visit my blog at http://jimlabs.herokuapp.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+unsubscr...@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/CAJ8y7Vd7OO_nMpOqt9_0br%3Dor0-FSHYi0a95ivCOkfqqHfrGNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] migration problems

2017-04-27 Thread Jim Ruther Nill
On Fri, Apr 28, 2017 at 9:17 AM, Joe Guerra  wrote:

> ok, I'm having difficulty with heroku, they are having some build
> problems...
>
> I'll try later.  I guess commenting out the # rename table in change def
> should work?
>
> I was puzzled because the column title started with a capital letter, it
> worked fine in sqlite, but generated errors in postgres.  (so the quickest
> fix for me was to edit the column in postgress directly).   I belive
> I skipped this migration before, but I forget how I did that.
>

is there anything that keeps you from using postgres for development?


>
> Thanks,
> Joe
>
> On Thursday, April 27, 2017 at 7:02:48 PM UTC-4, jim wrote:
>>
>>
>>
>> On Fri, Apr 28, 2017 at 8:54 AM, Joe Guerra  wrote:
>>
>>> Hi, I got stuck on a migration (basically to fix a column name).  I
>>> actually went into the table itself and corrected the problem.  My herkou
>>> migration gets stuck, and I've got other migrations behind it that aren't
>>> running.
>>>
>>
>> If you've already fixed the table manually, then you don't need to run
>> the migration at all.  You have 3 hackish options
>>
>> 1.  Just delete the migration and update the old migration so it uses the
>> correct column name.
>> 2.  Insert the timestamp of the migration that you want to skip to a
>> table called schema_migrations (not sure if this is
>> the exact name).  Rails basically checks this table to see which
>> migrations need to run.
>> 3.  Edit the migration so that it doesn't do anything, commit, deploy,
>> run db:migrate.  Edit the migration again, commit,
>> deploy, run db:migrate.  The second db:migrate should not run the edited
>> migration file.
>>
>> May I ask why you decided to fix the table manually?
>>
>>
>>> What should I do?
>>>
>>> Thanks,
>>> Joe
>>>
>>> --
>>> 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-ta...@googlegroups.com.
>>> To post to this group, send email to rubyonra...@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/rubyonrails-talk/9567374e-3003-4dde-8e3c-cf6c834247e4%
>>> 40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> -
>> visit my blog at http://jimlabs.herokuapp.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+unsubscr...@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/f4266b4f-c569-4820-891f-
> 2e7ba8a89126%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
visit my blog at http://jimlabs.herokuapp.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+unsubscr...@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/CAJ8y7Vf2uHq_nfSn3U%2Bk5TSwS1VhPVheRabtwgP0WFQ0dFsxaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] migration problems

2017-04-27 Thread Jim Ruther Nill
On Fri, Apr 28, 2017 at 8:54 AM, Joe Guerra  wrote:

> Hi, I got stuck on a migration (basically to fix a column name).  I
> actually went into the table itself and corrected the problem.  My herkou
> migration gets stuck, and I've got other migrations behind it that aren't
> running.
>

If you've already fixed the table manually, then you don't need to run the
migration at all.  You have 3 hackish options

1.  Just delete the migration and update the old migration so it uses the
correct column name.
2.  Insert the timestamp of the migration that you want to skip to a table
called schema_migrations (not sure if this is
the exact name).  Rails basically checks this table to see which migrations
need to run.
3.  Edit the migration so that it doesn't do anything, commit, deploy, run
db:migrate.  Edit the migration again, commit,
deploy, run db:migrate.  The second db:migrate should not run the edited
migration file.

May I ask why you decided to fix the table manually?


> What should I do?
>
> Thanks,
> Joe
>
> --
> 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+unsubscr...@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/9567374e-3003-4dde-8e3c-
> cf6c834247e4%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
visit my blog at http://jimlabs.herokuapp.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+unsubscr...@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/CAJ8y7VcnBcg5PWMxb0y2LtMVqQNuLAgfeOE3L8AKDdoJ4F7LHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Re: Looking for a part time project

2017-03-31 Thread Jim Ruther Nill
Hi Tariq,

I'm available! Just let me know what you need and see what we can set up.

Cheers,
Jim

On Fri, Mar 31, 2017 at 10:33 PM, tariq khan  wrote:

> Hi Jim,
>hope you will be fine, i read  your post  so i want  to contact
> you, i need  a  web developer who working on ruby on rails or  node.Js ,  i
> need  for my  project and  then for  coming next  project,  so  if it
> possible we can talk  about it,  its  a free classified website,  we can
> talk about  requirements after  i get your  response,
>
> Thanks & Regards,
>
> Tariq
>
> On Saturday, 11 March 2017 09:07:22 UTC+5, jim wrote:
>>
>> Hi,
>>
>> I am deeply sorry if this is an inappropriate post for this group.
>> Please disregard if it is.
>>
>> I'm Jim, a Rails developer for about 8 years (turning 9 in May).  I'm
>> looking for a part time
>> project that I could work on after office hours as I am away from my
>> family and have an
>> ample amount of time in the evening when I get home from work.  I am at
>> Brisbane,
>> Australia so my timezone is +10 UTC.  With that, it may be good to get
>> clients on the other
>> side of the globe so it's still office hours when I'm back at home.
>>
>> If you have something in mind, please don't hesitate to send me an email.
>>
>> Thank you and have a great weekend everyone!
>>
>> Best regards,
>> 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+unsubscr...@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/77f3f2a3-8bdc-416b-b4f9-
> 3b2d5d2f6113%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
visit my blog at http://jimlabs.herokuapp.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+unsubscr...@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/CAJ8y7VdTJoh78_yFZm3KaVZvczze52qP-7BtRn-sGazykO0%3DHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Re: Looking for a part time project

2017-03-16 Thread Jim Ruther Nill
Hi Falk,

I'm definitely interested.  My hourly rate is $50/hour.  I usually do a
trial period involving
1-2 simple tasks.  If you're keen, let me know :)

On Thu, Mar 16, 2017 at 5:04 PM, FALK LIEDER 
wrote:

> Hi Jim,
>
> I just saw your post on the Ruby on Rails list, and I have a project that
> might be interesting to you.
>
> I am a cognitive scientist at UC Berkeley and I would like to contract a
> Rails developer to add a relatively simple feature to an existing Ruby
> on Rails app. I am happy to pay standard hourly rates according to your
> qualifications. Your work would be contributing to scientific research
> on how to alleviate the problem of procrastination and help people
> become more productive.
>
> Concretely, we have programmed an experiment to study procrastination.
> The existing app presents participants with a todo list of writing
> tasks. The feature I would like you to add is recording the participants
> written responses to those assignments in the data base. The current
> version of the app is fully functional and available on Github. There is
> also a documentation for the existing code.
>
> Please don't hesitate to contact me with questions or quotes if this job 
> sounds interesting to you.
>
>
> Best wishes,
>
>
> Falk Lieder
> PhD candidate
> Computational Cognitive Science Lab @ UC Berkeley
> https://sites.google.com/site/falklieder/
>
> On Friday, March 10, 2017 at 8:07:22 PM UTC-8, jim wrote:
>>
>> Hi,
>>
>> I am deeply sorry if this is an inappropriate post for this group.
>> Please disregard if it is.
>>
>> I'm Jim, a Rails developer for about 8 years (turning 9 in May).  I'm
>> looking for a part time
>> project that I could work on after office hours as I am away from my
>> family and have an
>> ample amount of time in the evening when I get home from work.  I am at
>> Brisbane,
>> Australia so my timezone is +10 UTC.  With that, it may be good to get
>> clients on the other
>> side of the globe so it's still office hours when I'm back at home.
>>
>> If you have something in mind, please don't hesitate to send me an email.
>>
>> Thank you and have a great weekend everyone!
>>
>> Best regards,
>> 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+unsubscr...@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/e08afc41-d445-4fe9-b96b-
> 3d0bae33b0bf%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
visit my blog at http://www.jimruthernill.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+unsubscr...@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/CAJ8y7VcdnHzgk%3DurSAT7mpPrVgn8OT%2BNwsvUA0FTsmZ4ZHQ_Fg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Looking for a part time project

2017-03-10 Thread Jim Ruther Nill
Hi,

I am deeply sorry if this is an inappropriate post for this group.  Please
disregard if it is.

I'm Jim, a Rails developer for about 8 years (turning 9 in May).  I'm
looking for a part time
project that I could work on after office hours as I am away from my family
and have an
ample amount of time in the evening when I get home from work.  I am at
Brisbane,
Australia so my timezone is +10 UTC.  With that, it may be good to get
clients on the other
side of the globe so it's still office hours when I'm back at home.

If you have something in mind, please don't hesitate to send me an email.

Thank you and have a great weekend everyone!

Best regards,
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+unsubscr...@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/CAJ8y7Vf0%2BRsVZrDy-2yj%3D66M%2BZ4BxjF2bM-ogiGhVxR4cW3r%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] DateTime Enumerator

2015-09-26 Thread Jim Ruther Nill
On Sun, Sep 27, 2015 at 4:41 AM, Colin Law  wrote:

> On 26 September 2015 at 19:29, Jim Ruther Nill  wrote:
> > hmm maybe relevant
> > http://www.benknowscode.com/2014/02/ruby-date-time-range-intervals.html
>
> Thanks, if I interpret that correctly it is saying that what I am
> trying to do just doesn't work, that it is a limitation of ruby.  It
> is not a big problem as there are other simple ways of achieving the
> desired result.
>

Yeah looks like it.  I vaguely remember encountering something like this
before
but I can't quite put my finger on what I needed back then.  If you find a
way to
make it work using the step method, share it here :D


> Colin
>
> >
> > On Sun, Sep 27, 2015 at 12:03 AM, Colin Law  wrote:
> >>
> >> Can someone explain this for me please?
> >>
> >> range = (DateTime.now..DateTime.now+1.hour).step(10.minute)
> >>  => # >> 17:41:18 +0100:step(600 seconds)>
> >> 2.1.3 :009 > range.to_a
> >>  => [Sat, 26 Sep 2015 16:41:18 +0100]
> >>
> >> Not what I expected at all.
> >>
> >> 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+unsubscr...@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%3D0gLsXVDpNezdm0V3EJKh_XRhD6hdD1Bb%3DAJ4k2a2SoEqfjA%40mail.gmail.com
> .
> >> For more options, visit https://groups.google.com/d/optout.
> >
> >
> >
> >
> > --
> > -
> > visit my blog at http://www.jimruthernill.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+unsubscr...@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/CAJ8y7VdPOMAd13Ct83sKaqkFmw_xbsU-9CMNX67KsvZSJtZsdA%40mail.gmail.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+unsubscr...@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%3D0gLuaxwQ-rLs22vnWaTV3hNrBVX0Z0SVQFjNFdDHqHH4rGg%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
visit my blog at http://www.jimruthernill.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+unsubscr...@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/CAJ8y7Vds3Qx_Uy0j4Hnt5drY6fr4eSq6kmuAL%2BYR93iKm%2BHROg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] DateTime Enumerator

2015-09-26 Thread Jim Ruther Nill
hmm maybe relevant
http://www.benknowscode.com/2014/02/ruby-date-time-range-intervals.html

On Sun, Sep 27, 2015 at 12:03 AM, Colin Law  wrote:

> Can someone explain this for me please?
>
> range = (DateTime.now..DateTime.now+1.hour).step(10.minute)
>  => # 17:41:18 +0100:step(600 seconds)>
> 2.1.3 :009 > range.to_a
>  => [Sat, 26 Sep 2015 16:41:18 +0100]
>
> Not what I expected at all.
>
> 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+unsubscr...@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%3D0gLsXVDpNezdm0V3EJKh_XRhD6hdD1Bb%3DAJ4k2a2SoEqfjA%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
visit my blog at http://www.jimruthernill.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+unsubscr...@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/CAJ8y7VdPOMAd13Ct83sKaqkFmw_xbsU-9CMNX67KsvZSJtZsdA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Setting foreign keys, yet record.association_name returning nil

2015-09-05 Thread Jim Ruther Nill
On Saturday, September 5, 2015, Sadaf Noor  wrote:

> Also posted at stackoverflow:
> http://stackoverflow.com/questions/32414734/setting-foreign-keys-at-rails-yet-record-association-name-returning-nil
>
> ( Please don't downvote )
>
>
> 2015-09-05 21:22 GMT+06:00 Sadaf Noor  >:
>
>> Please help me to understand why this piece of rspec code is behaving
>> this way. I am setting product_id to my record, and it is asserting true,
>> but yet record.product not returning anything.
>>
>> product = FactoryGirl.create(:product)
>>
>> post :create, {:tshirt =>
>> FactoryGirl.attributes_for(:tshirt).stringify_keys.merge("product_id"=>
>> product.id.to_s) } #successful creation
>> expect(Tshirt.last.product_id).to eq(product.id)  # asserts true
>> puts Tshirt.last.product #prints nothing
>>
>>
Check how product is defined in the tshirt model. Also check the value of
product.id, it may be nil for all we know and tshirt.product_id is also nil
so they're equal.


> expect(Tshirt.last.product.size).to eq(product.size)  # exception!!! it
>> says, product = nil
>>
>>
>>
>> --
>>  Md. Sadaf Noor (@sadaf2605 )
>>  www.sadafnoor.com
>>
>
>
>
> --
>  Md. Sadaf Noor (@sadaf2605 )
>  www.sadafnoor.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+unsubscr...@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/CAAJ2eVqf%2BfSe7o%3DiA-PE3Sp_Bk23b-eNCiLumYvqB1iPXwiZQQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Sent from Gmail mobile

-- 
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+unsubscr...@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/CAJ8y7Vf6ryhm6mA94zvPbxZdTuW7xMYUgkTv%2BtNmh0R6qLXQOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] shifting to freelance

2014-12-17 Thread Jim Ruther Nill
Hi guys,

I am Jim, a Rails developer from the Philippines.  I worked as a remote
developer
for an Australia-based company for 4 years.

I've started using Rails around May of 2008 so I have extensive knowledge
of old
Rails versions.

I would like to try out being a full time freelancer so I'm currently
looking for projects
to work on right now.  If you are in need of developers, please don't
hesitate to reach
out.

Email: jvn...@gmail.com
Website: http://www.jimruthernill.com

Thank you and happy holidays!

-- 
-
visit my blog at http://www.jimruthernill.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+unsubscr...@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/CAJ8y7Vc_Dbqx83srSkR2JKS8Hqwm4vR8v%2B%2Bbf5Y198un9NeMdw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Looking for Senior RoR developers for leading IaaS Software vendor

2014-11-07 Thread Jim Ruther Nill
Hi Gavin, you'll need to provide your email if you wish people to reply to
you :)

On Fri, Nov 7, 2014 at 5:01 PM, Gavin Marriott  wrote:

> Are you a skilled Ruby on Rails Developer? Then our client would love to
> hear from you.
> My client is a global Pre-IPO company with four offices worldwide and is
> still growing rapidly.
> This is your chance to work in a fast paced, exciting environment and to
> get exposure to cutting edge technology in the IaaS software field.
> They are looking for someone who thrives on being able to work on their
> own as you will be one of the first in the RoR team in London with a
> view to leading a team in the next 6 months. They are very keen on
> people with a positive and enthusiastic attitude towards work and have a
> passion for new technology!
> In alignment with this, the company have a low attrition rate, invest in
> their employees and encourage symbiotic success.
> Should this sound of interest please give me a call ASAP so I can
> explain the role and company to you in more detail!
>
> Requirements -
>
> - Experience developing full-stack Ruby on Rails web applications
> - Experience testing in rails (Preferably Rspec)
> - Experience with PostGres
> - Comfortable in a Linux environment
> - Use of version control systems (Git)
>
> --
> 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+unsubscr...@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/df25145a5ac4c49c005edf55ea9d3de8%40ruby-forum.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
visit my blog at http://www.jimruthernill.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+unsubscr...@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/CAJ8y7VcbZUcRwgpFSnj2BKTZr%2BY9tyw%3DZjSAcPHsLS%2B5OE7EKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Using Dropbox in Rails

2014-11-01 Thread Jim Ruther Nill
I think I've tried the gem before but have since switched to the
chooser solution since it was a lot easier to implement.  In your
case, since you want to save to the user's dropbox folder, just
use the saver solution https://www.dropbox.com/developers/dropins/saver

On Sun, Nov 2, 2014 at 7:07 AM, Amber Flynn  wrote:

> Hi everyone,
>
> This is my first time using an API and I'm lost. I basically need to
> create a Rails app that authenticates a user, lists their dropbox
> folders, and allows the user to upload files to the folders.
>
> I know Dropbox has tutorials for all the above, but they're very
> confusing. I tried following them but I seem to miss something. I'm not
> always sure where the code goes in the rails app and I'm not sure
> whether I need to install gems for authentication and file upload (do I
> need gems like Sorcery or Carrierwave? or is the Dropbox gem alone
> sufficient?)
>
> I searched for tutorials explaining how use the Dropbox API but couldn't
> find anything that made any sense. They all assume that the person
> reading the tutorial knows where each fragment of code goes, which isnt
> my case.
>
> Could anyone recommend/share resources or tutorials on how to achieve
> the above? I'd really appreciate it!
>
> thanks a lot!
>
> --
> 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+unsubscr...@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/1c5c191714184cb420cfaedb4436b81d%40ruby-forum.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
visit my blog at http://www.jimruthernill.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+unsubscr...@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/CAJ8y7VcTSyTb0Xbvm82pQW%2BqMhdgPr9iqM_SRVX8JupbfzD7Ow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] One huge table or separate tables? design issue

2014-10-12 Thread Jim Ruther Nill
you can also run a task that archives past dates to a duplicate table since
you'll
rarely need them. maybe you can keep 1 month data in the table that you're
writing to.  this way, you won't have to worry about the exponential growth
of
the table you're always accessing.

On Sun, Oct 12, 2014 at 7:12 PM, Colin Law  wrote:

> On 12 October 2014 11:54, Colin Law  wrote:
> > On 12 October 2014 11:34, Yongbiao Long  wrote:
> >> On Sun, Oct 12, 2014 at 5:17 PM, Colin Law  wrote:
> >>> Are you sure your basic design is appropriate?  Having 100,000
> >>> associated records per user seems very high.  Are you able to explain
> >>> what is in those records in case an alternative can be suggested?
> >>
> >> Thank you Colin! I'm implementing a railway ticket-booking system just
> >> for learn purpose, not for production.
> >> Now I try to explain it:
> >> Suppose a train has 20 stations along the way. It has 1000 seats to
> >> sell. Table A store one train's information in a row. I want table B
> >> to store every seat's information. I design table B as follow
> >>
> >> train_id:
> >> start_city_id:
> >> end_city_id:
> >> seat_id:
> >> availability: boolean type
> >> date:
> >>
> >> For one train, the number of start_city_id and end_city_id's
> >> combinations is 19+18+...+1=190, the number of possible date is
> >> 20(people can book tickets in 20 days), and possible seat_id's number
> >> is 1000. The total number of rows for one train is
> >> 190*1000*20=3,800,000. So huge..
> >
> > The first point is that you should only add rows as seats are booked,
> > use that fact that there is no row to indicate that there is no
> > booking.
> > Secondly, what is the date?  Is that the date of the journey or the
> > date of the booking?  I don't understand why you have multiplied the
> > number of trains by 20 days.  If it is the date of the journey then
> > consider having a Journeys table which is a particular train on a
> > particular day.
> > Thirdly I don't understand why you have 20 factorial for the city
> > combinations.  Is it not true that if a seat is booked from station 1
> > to station 3 then that implies a booking 1 to 2 and 2 to 3?   In which
> > case you do not separate rows for bookings 1 to 2, 2 to 3, and 1 to 3.
>
> In fact thinking further, I would probably turn the problem around and
> have a bookings table, specifying the journey, the stations, and the
> seat (or seats).
>
> 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+unsubscr...@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%3D0gLv77Kt-sH6rw0djfqrkNUycnkTimEw6anNg_oZSg-YOYg%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
visit my blog at http://jimlabs.herokuapp.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+unsubscr...@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/CAJ8y7Vf2ShaMFvah%2B0%3DWv%3DWqdrhWH_f5Zgi2bNLuL%3DHPziVOyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Scaling/optimizing a slow ruby on rails application.

2014-07-23 Thread Jim Ruther Nill
On Wed, Jul 23, 2014 at 10:59 AM, Michael Solovyov 
wrote:

>  Hi everyone,
>
>
>
>  My name is Michael Solovyov and I'm the co-founder & CTO of a
> rails-based start-up. We have built a product for other businesses to help
> their users adopt their products.
>
>
>
>  We've built the application, delivered to a few customers and now we've
> hit scaling and performance issues.
>
>
>
>  I'd love your feedback on how we proceed as we try to resolve them:
>
>
>
>  1) These are the problems we've encountered:
>
> The main user dashboard takes between 7-15 seconds to load. The maximum
> requests per second that we can support are 100-150.
>
>
>
>  2) Why we think they're happening:
>
> We're using couchdb with an ORM that has our data modeled relationally.
> This causes the ORM to launch an extraordinary amount of http requests to
> couchdb to load all our data. The more data and users in the project, the
> longer the delay. There's also potentially inefficient code, extra loops
> etc. We're not using caching to it's fullest extent.
>
>
>
>  3) What we're using/what we've done:
>
> Our architecture: rails '3.2.12', ruby 1.9.3p374, nginx + unicorn (main
> server), elasticsearch (separate server), couchdb (separate server). All on
> AWS.
>

one easy way you can improve is to move to a more recent version of ruby.
 there's a big improvement between
2.0 and 1.9.3 (and it's already 2.1.2) so you might want to look into that
first since it's easier than improving the
code performance.


> We've added some view level caching where we can get away with stale data.
>
> We've tried using higher tiered/ssd aws servers but it doesn't look to be
> our main bottleneck.
>
>
>
>  4) How we plan on completing it:
>
> We're mostly done a rewrite to migrate our data and data model to
> activerecord. We've hit a snag in migrating s3 attachment code built into
> the couchdb ORM that we're using. Following the completion of the migration
> to sql/activerecord we are going to do the following in an attempt to
> increase performance:
>
>
>
>  A. Use percono mysql server.
>
>
>
>  B. Run tools such as bullet to analyze performance and where we might
> have bad queries/lookups.
>
>
>
>  C. Update to latest Rails and Ruby versions.
>
>
>
>  D. Look into Puma and paralelization of DB access calls.
>
>
>
>  E. Break apart the application into separate services.
>
>
>
>  5) What we don't know right now:
>
> Whether switching to Activerecord or any of the above ideas will
> inherently give us any performance benefits.
>
> Whether we will have any other unexpected surprises or loss of
> functionality due to switching to ActiveRecord.
>
> How long this all will take and whether there's other areas that we need
> to focus to get sub 1 second performance that we're missing.
>
>  Do you all have any feedback/ideas/insights completing projects like
> these?
>
>
>
>  In particular, I would be curious about:
>
>
>
>  a) How would you approach it?
>
>
>  b) Anything that's worked for you in the past on suitable projects?
>
>
>  c) Anything to avoid doing?
>
>
>  d) Where to find good additional team members & advisors to help us
> complete the project?
>
> e) How long to expect it to take?
>
>
>
>
>
>
>  Here are our application rake stats:
> http://pastie.org/private/qrxkytk4uur9odndydv5dq
>
> --
> 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+unsubscr...@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/dab7f05f-a3bd-4716-8f9d-7b8007f5582d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
visit my blog at http://jimlabs.herokuapp.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+unsubscr...@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/CAJ8y7Vd0Zfs80iENR9%2BuGev5B2vh5CFXVk_OO0VPpooBnC-TXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] ruby on rails

2014-07-15 Thread Jim Ruther Nill
On Wed, Jul 16, 2014 at 1:13 AM, Carlo Giustinoni <
carlo.giustin...@gmail.com> wrote:

> this is the worst installation package I have ever encountered, I
> installed using www.railsinstaller.org, I installed the VS2010 shell,
> when I try to generate script for anew project I get this error
>
> Starting Generate 'script\rails generate scaffold post title:string
> body:text created_at:datetime' ...
>
> C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/rbconfig.rb:7:in
> `': ruby lib version (1.9.2) doesn't match executable
> version (1.9.3) (RuntimeError)
>
> from C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/rbconfig.rb:5:in ` (required)>'
>
> from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems.rb:30:in `require'
>
> from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems.rb:30:in ` (required)>'
>
> from :1:in `require'
>
> from :1:in `'
>
> Generate completed - now synchronizing project
> Project synchronization complete
>
> The support staff doesn't support Rails , they say they support only VS
> errors, they have been of no help
>

hi!

this isn't an answer at all but I'd like to say it anyway.

I have very little experience using Rails in windows (used it about 5 years
ago before switching to cygwin).  If you are
serious about learning Rails, use a virtual box and install a linux distro
to make it easier for you.  I'm pretty sure this
will not be the first error you will encounter when developing in windows.

 --
> 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+unsubscr...@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/5709e231-14ca-43fb-8b78-6f3648595582%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
visit my blog at http://jimlabs.herokuapp.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+unsubscr...@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/CAJ8y7Vdjg%3DuEs6c_08%2BTAuFPk4W6uHKF6E2eb7asE3njPEpk9g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Morons in our midst (re: "important news")

2014-05-27 Thread Jim Ruther Nill
+1 I think it's not important news if Rails is gay or not


On Wed, May 28, 2014 at 11:16 AM, Ken D'Ambrosio  wrote:

> Hi, all.  I'm not a frequent contributor -- I'm just ramping up on Rails.
>  But I've been on the 'Net for quite some time.  And back in the days of
> yore, on Usenet, we had moderated lists.  In much the same vein, I suggest
> we stop allowing anonymous submissions to the online forum (which I
> *believe* is currently the default).  It may go marginally against the
> spirit of openness, but it *would* stop (or at least vastly reduce) the
> ability of idiots like the one currently spamming the list from doing just
> that.
>
> Discussion?
>
> -Ken
>
> --
> 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+unsubscr...@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/894db21ce0e56786493ac75d405d9d16%40webmail.jots.org
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@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/CAJ8y7VcSFohnvTLVcdaWH3sUitZGav2ybnAmVd7L67N2KipnNw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] How to get around a reserved word

2014-03-05 Thread Jim Ruther Nill
On Wed, Mar 5, 2014 at 9:32 PM, Walter Lee Davis  wrote:

>
> On Mar 5, 2014, at 6:40 AM, Frederick Cheung wrote:
>
> >
> >
> > On Wednesday, March 5, 2014 7:02:34 AM UTC, Walter Lee Davis wrote:
> > I need to use the model name 'Action' (which will not work in Rails
> 4.0.3) for business reasons (it's a product name). If I name the actual
> model something else, is there any way to (maybe with mod_rewrite) make the
> URL appear the way I need it to while keeping everything working in Rails?
> >
> > I've tried using the controller flag in routes.rb to try to fix this,
> and it seems to work, but causes a lot of problems elsewhere -- basically
> anything where I use the automatic URLs, like
> >
> > link_to 'Link text', @instance_var
> >
> >
> > resources :foos, :as => :action ?
> >
>
> Thanks, I tried that first, and couldn't get the forms to work. What did
> work was this (although it's quite a hack, routes-wise):
>
> resources :fw_actions :as => :action
> resources :fw_actions
>
> The second line was required in order to support POST and PUT and DELETE,
> so I may go through these and put :only => [:post, :put, :delete] on the
> latter, and :without on the former.
>
> I couldn't find any way to have form_for work in the absence of that
> duplicate set of routes.
>

You can remove the second line.  In order for form_for to work, you need to
manually set
the url instead of just form_for @instance_var.  I've tested this out using
the following routes

resources :pages, as: :foo

which gave the following routes

  foo_index GET/pages(.:format)   pages#index
POST   /pages(.:format)   pages#create
new_foo GET/pages/new(.:format)   pages#new
   edit_foo GET/pages/:id/edit(.:format)  pages#edit
foo GET/pages/:id(.:format)   pages#show
PATCH  /pages/:id(.:format)   pages#update
PUT/pages/:id(.:format)   pages#update
DELETE /pages/:id(.:format)   pages#destroy

Try the following for your forms

# new action
form_for @instance_var, url: foo_index_path, html: { method: :post }

# edit
form_for @instance_var, url: foo_path(@instance_var), html: { method: :put }


>
> Walter
>
> > Fred
> >
> >
> > --
> > 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+unsubscr...@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/af8c8dd9-dde6-4d15-aca2-1de45a2666a7%40googlegroups.com
> .
> > For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> 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+unsubscr...@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/C70782AC-EFC0-4F09-9927-C5A4AB45E57A%40wdstudio.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@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/CAJ8y7Ve%3DnuNmEvBoC7SemU0WB%3DJk1fjnm-hz5Z1k10HONuN6oA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Rails] Asset pre-compilation unbearably slow: Have we outgrown asset pipeline?

2013-06-27 Thread Jim Ruther Nill
On Fri, Jun 28, 2013 at 12:11 AM, Bryan Migliorisi wrote:

> Our application is a very large (read: "enterprise") Single Page
> Application.
>
> Even though our app is 99% client side with a Java RESTful API, we built
> the web application on top of rails because the Asset Pipeline seemed like
> a a great fit for us.  And until recently, it was.
>
> Our application has several hundred CoffeeScript and SASS files in it (as
> we've broken our code down in to many smaller pieces for reusability).
>
> We deploy to Heroku, who automatically compiles assets for us. It used to
> be pretty fast. Then it was a minute. Then 2. Then 5. Now, we have
> apparently hit the upper limit that Heroku is willing to wait for assets to
> compile (15 mins).
>
> Pre-compiling the assets on a developers machine is possible but its error
> prone and doesnt solve the problem of our compilation process taking
> forever.
>
> I notice that even some of our smaller CoffeeScript files (~50 lines) take
> 250ms to compile. This quickly adds up with the amount of files we have.
>
> On my i7 MBA, assets:precompile:primary takes around 5 minutes and
>  assets:precompile over 10 minutes. I think (but not sure) the biggest
> problem is that it appears that a new nodejs process is started for every
> CoffeeScript file and each start takes a bit of time before the file is
> even processed.
>
> We are on the latest Rails 3.2.x.  Is there a better way? Is there any
> tuning I can do for improving the speed of compilation?
>
try looking at https://github.com/ndbroadbent/turbo-sprockets-rails3


>  --
> 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+unsubscr...@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/352dc6b7-fae9-4f70-8d08-101c901852d4%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@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/CAJ8y7VfgdNUh44rUnRJSA%3D_BXvpyP6ikOhToV3FM7O2C_z7yJg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Looping through hash and sub-hash.

2013-06-19 Thread Jim Ruther Nill
On Thu, Jun 20, 2013 at 10:30 AM, Patrick Curl wrote:

> # Need a little push in the right direction.
> @prices = [
>   "amazon_new" => [
>   "image" => "imageurl.com",
>   "url" => "bookurl.com",
>   "price" => 45.55
>   ],
>
>   "amazon_used" => [
>   "image" => "2ndImageUrl.com",
>   "url" => "2ndbookurl.com",
>   "price" => 67.45
>   ]
> ]
>
> @prices.each do |p|
>   p.each do |x|
>   x["image"]
> # Can't convert string into integer.
>
>
You get this error when you try to access an array as a hash. ie

array = (1..4).to_a
array['image'] # can't convert string into integer

try to look again at how @prices is declared. judging from the code
you pasted, you want @prices to be a hash but it's using square braces.


>   end
> end
>
>  --
> 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+unsubscr...@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/d2d1f766-1af9-40a5-9d66-45b34037e5b0%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@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/CAJ8y7VfhbBBtyY%3DpqyD6x%3DQWuJoRWx7M3W%3Djc4WVQJReyGYo_g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Paperclip thumbnail generation uses magic?

2013-06-12 Thread Jim Ruther Nill
I haven't seen the paperclip code but I think you can look at the
preprocessors used by default by paperclip.
You usually see logs when paperclip does some processing using rmagick
which may be a clue as to what
part of the lib you want to look at.


On Wed, Jun 12, 2013 at 11:15 PM, Walter Lee Davis wrote:

> I have been using CarrierWave for file uploads on a site which needs to
> accept a really wide range of different movie formats, stills, PDFs... And
> I have been struggling with making thumbnails of certain formats. After
> much yak-shaving with ffmpeg and imagemagick and Rmagick, I finally decided
> to do a little spike app with nothing but Paperclip. I set up the simplest
> thing that could possibly work:
>
> has_attached_file :blob, :styles => { :thumb => ["320x320>", :png], :large
> => ["1500x1500>", :png] }
>
> And no matter what format (within reason) I pass to it, I get a nicely
> formed PNG format thumbnail and large preview image. PSD, PDF, TIFF, MOV,
> M4V -- it Just Works™. And I cannot figure out how it is doing this,
> despite reading through the source code for quite a while.
>
> The reason why I need to access the magic is that while I am getting a
> nice thumbnail from any movie format I pass in, I am getting the very first
> frame of the movie (usually black) rather than a few seconds into the clip.
> In my CarrierWave converter, I had a custom offset time defined for this.
> But I cannot see where Paperclip is defining what to do with a video to
> generate a PNG image so I can alter this default.
>
> There are tons of examples on SO and the Web in general, showing how to
> create a custom video thumbnailer and transcoder, but I would like to avoid
> rebuilding this wheel that Paperclip seems to have hewn out of pure Elven
> magick.
>
> Thanks in advance,
>
> Walter
>
> --
> 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+unsubscr...@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/87E1CB56-F23E-4EF2-A760-9F6D6A2C0B74%40wdstudio.com?hl=en-US
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@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/CAJ8y7Vdt3BKPzFd%2BzQDsLnNA2G0%2BY2d0pa9fc4RQFVVH6kLuhA%40mail.gmail.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: How to run view helpers from rails console?

2013-05-29 Thread Jim Ruther Nill
i think you can also use app for the url_helpers

app.posts_path for example


On Thu, May 30, 2013 at 2:21 PM, Frederick Cheung <
frederick.che...@gmail.com> wrote:

>
>
> On Wednesday, May 29, 2013 10:25:59 PM UTC+1, Ruby-Forum.com User wrote:
>>
>> With
>> > rails console --sandbox
>> I cant test my models, save data to db and all will be rolled back
>> after.
>>
>> But is it possible to test view helpers from console? I talk about these
>> helpers:
>> > post_path
>> > link_to
>> > url_for
>> > edit_post_path
>> > new_post_path
>>
>> When I call them, I get an error:
>> irb(main):003:0> post_path(:post)
>> NameError: undefined local variable or method `post_path' for
>> main:Object
>>
>> Is there a way to call those methods from Rails console? Through which
>> object do I need to call them?
>>
>>
> The routing helpers are all defined on Rails.application.routes.url_helpers
>
> The other helpers are defined on the helper object
>
>  helper.number_with_precision(1.1235)
>
> This doesn't always work - some of the helpers rely on their being a
> controller/request around and these won't be able to run.
>
> Fred
>
>
>> --
>> 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+unsubscr...@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/9604e641-9fe4-4e34-b746-14b781e3a6c9%40googlegroups.com?hl=en-US
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@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/CAJ8y7Ve6gmXpcnonwFn26KeVXqrScBTEm-FOKaZa53aGrHun2A%40mail.gmail.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Why does Hash#values_at not working?

2013-04-30 Thread Jim Ruther Nill
p h.values_at[*ar]

should be

p h.values_at(*ar)


On Wed, May 1, 2013 at 12:50 PM, Love U Ruby  wrote:

> While the below code working :-
>
>
> m = {:a => 2, :b => 3,:c => 44,:g => 14}
> a = [:a,:b,:g]
> p m.values_at(*[:a,:b,:g]) #=> [2, 3, 14]
>
> why the below not working?
>
> h = {
>   'arg0' => '126150656000',
>   'arg1' => 'Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz',
>   'arg2' => '2790',
>   'arg3' => '3276320768',
>   'arg4' => '8467496960',
>   'arg5' => 'Windows 7',
>   'arg7' => 'amd64',
>   'arg6' => '6.1',
>   'arg8' => '2',
>   'arg9' => '1920',
>   'arg10' => '1200',
>   'arg11' => '32',
> }
>
>
> p ar = h.keys.sort_by{|s| s[3..-1].to_i}
> p h.values_at[*ar]
> #=>`[]': wrong number of arguments (12 for 1..2) (ArgumentError)
>
> Where did I mistake?
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] joining 2 tables

2013-01-31 Thread Jim Ruther Nill
On Thu, Jan 31, 2013 at 9:52 PM, Fabian Peter  wrote:

> Hello,
>
> I'm trying to join 2 tables with ruby on rails 3.2.
>
> rails generate model product name:string
> rails generate model price product_id:integer price:integer
> date:datetime
>
> product.rb:
> class Product < ActiveRecord::Base
>   has_many :prices
> end
>
> price.rb:
> class Price < ActiveRecord::Base
>   belongs_to :product
> end
>
> What is the most efficient way to get all products including the latest
> price into the View.
>
> Some tries didnt work for this:
>
> @test = Product.includes(:prices).all
> I didnt find anything about the prices in @test.
>

@test contains an array of products.  to get the prices, try

@test.each do |product|
  product.prices.each do |price|
p price.price
  end
end


>
> Thanks for help!
>
> Fabian
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Shameless plug

2013-01-30 Thread Jim Ruther Nill
Hey guys,

If you have time to read something today, please visit the latest entry on
NetEngine's blog.
http://netengine.com.au/blog/learning-while-conducting-the-triggerapp-upgrade/

This will grant me a case of beer if I gain at least 60 views today. hehe

Thanks!

-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] case study

2013-01-30 Thread Jim Ruther Nill
On Thu, Jan 31, 2013 at 7:08 AM, oto iashvili
wrote:

> hi
>
> thanks for answer sorry I quite new in RoR. If I do how u said, will I
> have to validate "manually" all the attributes for details ?
>

Now that you've asked that, I'm not sure.  You can try to use
validates_associated and use a before_validation callback


>
> Le mercredi 30 janvier 2013 15:27:43 UTC+1, jim a écrit :
>>
>>
>> On Wed, Jan 30, 2013 at 6:48 PM, oto iashvili wrote:
>>
>>> I want to do
>>> @ad = Ad.attributes(params[:ad])
>>> maybe Im wrong, but as I understood about polymorphic in rails, this
>>> would thow an error say that  ad_real_estate_details does not exist
>>>
>>> as they explained here http://stackoverflow.**com/**
>>> questions/3969025/accepts-**nest**ed-attributes-for-with-**belongs**
>>> -to-polymorphic
>>>
>>
>> As I've said, don't use accepts_nested_attributes_for.  Create a getter
>> and setter method for each kind of details that you want.
>> If you don't want to do that, create an attr_accessor for the details,
>> and create the detail record in a callback.
>>
>>
>>
>>>
>>>
>>> Le mardi 29 janvier 2013 13:39:18 UTC+1, jim a écrit :




 On Tue, Jan 29, 2013 at 7:41 PM, oto iashvili 
 wrote:

> Hi,
>
> thanks for answer. My pb with polymorphic is that I would have to
> create first in db a ligne for ad_real_estate_details and then create my
> ad, what is non sense for me, in terms of logic.
> and it might brings some pb as I read there http://stackoverflow.**com
> **/questions/3969025/accepts-**nes**ted-attributes-for-with-**belong**
> s-to-polymorphic
>
> lets have another example which is almost the same
>
> image we have Student (age, classe, ...)  and Teacher (subject_taught)
> classes that inherit from User classes. I would be non sense to create
> first a Teacher entity, and then to link it to User, no ?
>

 Why are you thinking of creating the details first?  Why not create the
 ad first, then add the details later? Sometimes,
 accepts_nested_attributes_for is not always the answer for creating
 association records.  Try to look into virtual attributes
 and callbacks.


>
>
> Le lundi 28 janvier 2013 01:10:30 UTC+1, jim a écrit :
>>
>>
>>
>>
>> On Mon, Jan 28, 2013 at 6:27 AM, oto iashvili > > wrote:
>>
>>> hi,
>>>
>>> i' trying to re-create my project from php to rails. But now Im
>>> faced with a pb to witch I had solution with php, but I cant figure how 
>>> to
>>> make it work with rails
>>>
>>> here my tables
>>>
>>> ads
>>>   id
>>>   category_id
>>>   title
>>>   text
>>>
>>> ad_real_estate_details
>>>   id
>>>   ad_id
>>>   nb_room
>>>   floor
>>>
>>> ad_car_details
>>>   id
>>>   ad_id
>>>   color
>>>   brand
>>>
>>> here what I succeed to do
>>>
>>>
>>> class Ad < ActiveRecord::Base
>>>   attr_accessible :category_id :title, :text, :ad_real_estate_details
>>>   has_one :ad_real_estate_details
>>>   accepts_nested_attributes_for :ad_real_estate_details,
>>> allow_destroy: true
>>> end
>>>
>>> class AdRealEstateDetail < ActiveRecord::Base
>>>   belongs_to :ad
>>>   validates :ad_id, presence: true
>>> end
>>>
>>> but this only work for other category than real_estate
>>>
>>> so I was thinking of polymorphism, but polymorphism mean I should
>>> add a reference in my "ad" table to the detail tables, and remove
>>> annonce_id from detail tables , what I thing is non-sense as some ads 
>>> can
>>> have no details, but details are non-sense without an ad.
>>>
>>
>> i think you have it right when you mentioned using polymorphic
>> associations.  it is fine to leave the polymorphic association
>> nil if the ad has no details if that's what you're worried about.
>>
>>
>>>
>>> I was also thinking of a class AdDetails, and  AdRealEstateDetail
>>> would inherite from it, but this is not possible with rails as all
>>> subclasses will share the same table
>>>
>>> does anyone have a solution for this kind of problem ?
>>>
>>> thanks
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ruby on Rails: Talk" group.
>>> To post to this group, send email to rubyonra...@googlegroups.**com.
>>> To unsubscribe from this group, send email to rubyonrails-ta...@**
>>> googlegroups.com.
>>>
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/**msg/rubyonrails-talk/-/**GLpFbbHm0
>>> ogJ

Re: [Rails] Multiple forms to create multiple records for multiple users

2013-01-30 Thread Jim Ruther Nill
On Wed, Jan 30, 2013 at 5:34 PM, Abdullah Esmail
wrote:

> Hello.
> I have come across a scenario where I need to save multiple records for
> multiple users on the same page.
>
> User has_many :shifts
> Shift belongs_to :user
>
> I need to show multiple shifts for each user on the same page and the
> administrator will just enter some values and click save.
>
> Example:
> user1:  -  - 
> user2:  -  - 
> user3:  -  - 
> [save]
>
> What's the best way to tackle this problem in rails?
>

This all depends on how you setup the form in your views.  I suggest you
create a spectific action, outside of the 7 crud actions, to handle the data
that you get when you do this.

As for the form, I think the names of the elements should be

shifts[][user_id] for the user_id
shifts[][shifts][] for the 3 shift values

you'll receive a hash that looks like

shifts: [{ user_id: 1, shifts: [1,2,3] }, { user_id: 2, shifts: [1,2,3] }]

on the controller. good luck!


>
> Thank you.
>
> --
> 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+unsubscr...@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/msg/rubyonrails-talk/-/72HFVK-JilIJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] case study

2013-01-30 Thread Jim Ruther Nill
On Wed, Jan 30, 2013 at 6:48 PM, oto iashvili
wrote:

> I want to do
> @ad = Ad.attributes(params[:ad])
> maybe Im wrong, but as I understood about polymorphic in rails, this would
> thow an error say that  ad_real_estate_details does not exist
>
> as they explained here http://stackoverflow.**
> com/questions/3969025/accepts-**nested-attributes-for-with-**
> belongs-to-polymorphic
>

As I've said, don't use accepts_nested_attributes_for.  Create a getter and
setter method for each kind of details that you want.
If you don't want to do that, create an attr_accessor for the details, and
create the detail record in a callback.



>
>
> Le mardi 29 janvier 2013 13:39:18 UTC+1, jim a écrit :
>>
>>
>>
>>
>> On Tue, Jan 29, 2013 at 7:41 PM, oto iashvili wrote:
>>
>>> Hi,
>>>
>>> thanks for answer. My pb with polymorphic is that I would have to create
>>> first in db a ligne for ad_real_estate_details and then create my ad, what
>>> is non sense for me, in terms of logic.
>>> and it might brings some pb as I read there http://stackoverflow.**
>>> com/questions/3969025/accepts-**nested-attributes-for-with-**
>>> belongs-to-polymorphic
>>>
>>> lets have another example which is almost the same
>>>
>>> image we have Student (age, classe, ...)  and Teacher (subject_taught)
>>> classes that inherit from User classes. I would be non sense to create
>>> first a Teacher entity, and then to link it to User, no ?
>>>
>>
>> Why are you thinking of creating the details first?  Why not create the
>> ad first, then add the details later? Sometimes,
>> accepts_nested_attributes_for is not always the answer for creating
>> association records.  Try to look into virtual attributes
>> and callbacks.
>>
>>
>>>
>>>
>>> Le lundi 28 janvier 2013 01:10:30 UTC+1, jim a écrit :




 On Mon, Jan 28, 2013 at 6:27 AM, oto iashvili 
 wrote:

> hi,
>
> i' trying to re-create my project from php to rails. But now Im faced
> with a pb to witch I had solution with php, but I cant figure how to make
> it work with rails
>
> here my tables
>
> ads
>   id
>   category_id
>   title
>   text
>
> ad_real_estate_details
>   id
>   ad_id
>   nb_room
>   floor
>
> ad_car_details
>   id
>   ad_id
>   color
>   brand
>
> here what I succeed to do
>
>
> class Ad < ActiveRecord::Base
>   attr_accessible :category_id :title, :text, :ad_real_estate_details
>   has_one :ad_real_estate_details
>   accepts_nested_attributes_for :ad_real_estate_details,
> allow_destroy: true
> end
>
> class AdRealEstateDetail < ActiveRecord::Base
>   belongs_to :ad
>   validates :ad_id, presence: true
> end
>
> but this only work for other category than real_estate
>
> so I was thinking of polymorphism, but polymorphism mean I should add
> a reference in my "ad" table to the detail tables, and remove annonce_id
> from detail tables , what I thing is non-sense as some ads can have no
> details, but details are non-sense without an ad.
>

 i think you have it right when you mentioned using polymorphic
 associations.  it is fine to leave the polymorphic association
 nil if the ad has no details if that's what you're worried about.


>
> I was also thinking of a class AdDetails, and  AdRealEstateDetail
> would inherite from it, but this is not possible with rails as all
> subclasses will share the same table
>
> does anyone have a solution for this kind of problem ?
>
> thanks
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonra...@googlegroups.**com.
> To unsubscribe from this group, send email to rubyonrails-ta...@**
> googlegroups**.com.
>
> To view this discussion on the web visit https://groups.google.com/d/*
> *ms**g/rubyonrails-talk/-/**GLpFbbHm0**ogJ
> .
> For more options, visit 
> https://groups.google.com/**grou**ps/opt_out
> .
>
>
>



 --
 -----
 visit my blog at http://jimlabs.heroku.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-ta...@**googlegroups.com.
>>>
>>> To post to this group, send email to rubyonra...@googlegroups.**com.
>>> To view this discus

Re: [Rails] case study

2013-01-29 Thread Jim Ruther Nill
On Tue, Jan 29, 2013 at 7:41 PM, oto iashvili
wrote:

> Hi,
>
> thanks for answer. My pb with polymorphic is that I would have to create
> first in db a ligne for ad_real_estate_details and then create my ad, what
> is non sense for me, in terms of logic.
> and it might brings some pb as I read there
> http://stackoverflow.com/questions/3969025/accepts-nested-attributes-for-with-belongs-to-polymorphic
>
> lets have another example which is almost the same
>
> image we have Student (age, classe, ...)  and Teacher (subject_taught)
> classes that inherit from User classes. I would be non sense to create
> first a Teacher entity, and then to link it to User, no ?
>

Why are you thinking of creating the details first?  Why not create the ad
first, then add the details later? Sometimes, accepts_nested_attributes_for
is not always the answer for creating association records.  Try to look
into virtual attributes
and callbacks.


>
>
> Le lundi 28 janvier 2013 01:10:30 UTC+1, jim a écrit :
>>
>>
>>
>>
>> On Mon, Jan 28, 2013 at 6:27 AM, oto iashvili wrote:
>>
>>> hi,
>>>
>>> i' trying to re-create my project from php to rails. But now Im faced
>>> with a pb to witch I had solution with php, but I cant figure how to make
>>> it work with rails
>>>
>>> here my tables
>>>
>>> ads
>>>   id
>>>   category_id
>>>   title
>>>   text
>>>
>>> ad_real_estate_details
>>>   id
>>>   ad_id
>>>   nb_room
>>>   floor
>>>
>>> ad_car_details
>>>   id
>>>   ad_id
>>>   color
>>>   brand
>>>
>>> here what I succeed to do
>>>
>>>
>>> class Ad < ActiveRecord::Base
>>>   attr_accessible :category_id :title, :text, :ad_real_estate_details
>>>   has_one :ad_real_estate_details
>>>   accepts_nested_attributes_for :ad_real_estate_details, allow_destroy:
>>> true
>>> end
>>>
>>> class AdRealEstateDetail < ActiveRecord::Base
>>>   belongs_to :ad
>>>   validates :ad_id, presence: true
>>> end
>>>
>>> but this only work for other category than real_estate
>>>
>>> so I was thinking of polymorphism, but polymorphism mean I should add a
>>> reference in my "ad" table to the detail tables, and remove annonce_id from
>>> detail tables , what I thing is non-sense as some ads can have no details,
>>> but details are non-sense without an ad.
>>>
>>
>> i think you have it right when you mentioned using polymorphic
>> associations.  it is fine to leave the polymorphic association
>> nil if the ad has no details if that's what you're worried about.
>>
>>
>>>
>>> I was also thinking of a class AdDetails, and  AdRealEstateDetail would
>>> inherite from it, but this is not possible with rails as all subclasses
>>> will share the same table
>>>
>>> does anyone have a solution for this kind of problem ?
>>>
>>> thanks
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ruby on Rails: Talk" group.
>>> To post to this group, send email to rubyonra...@googlegroups.**com.
>>> To unsubscribe from this group, send email to rubyonrails-ta...@**
>>> googlegroups.com.
>>>
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> msg/rubyonrails-talk/-/**GLpFbbHm0ogJ
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>> --**--**-
>> visit my blog at http://jimlabs.heroku.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+unsubscr...@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/msg/rubyonrails-talk/-/zT4pri8N4GUJ.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] case study

2013-01-27 Thread Jim Ruther Nill
On Mon, Jan 28, 2013 at 6:27 AM, oto iashvili
wrote:

> hi,
>
> i' trying to re-create my project from php to rails. But now Im faced with
> a pb to witch I had solution with php, but I cant figure how to make it
> work with rails
>
> here my tables
>
> ads
>   id
>   category_id
>   title
>   text
>
> ad_real_estate_details
>   id
>   ad_id
>   nb_room
>   floor
>
> ad_car_details
>   id
>   ad_id
>   color
>   brand
>
> here what I succeed to do
>
>
> class Ad < ActiveRecord::Base
>   attr_accessible :category_id :title, :text, :ad_real_estate_details
>   has_one :ad_real_estate_details
>   accepts_nested_attributes_for :ad_real_estate_details, allow_destroy:
> true
> end
>
> class AdRealEstateDetail < ActiveRecord::Base
>   belongs_to :ad
>   validates :ad_id, presence: true
> end
>
> but this only work for other category than real_estate
>
> so I was thinking of polymorphism, but polymorphism mean I should add a
> reference in my "ad" table to the detail tables, and remove annonce_id from
> detail tables , what I thing is non-sense as some ads can have no details,
> but details are non-sense without an ad.
>

i think you have it right when you mentioned using polymorphic
associations.  it is fine to leave the polymorphic association
nil if the ad has no details if that's what you're worried about.


>
> I was also thinking of a class AdDetails, and  AdRealEstateDetail would
> inherite from it, but this is not possible with rails as all subclasses
> will share the same table
>
> does anyone have a solution for this kind of problem ?
>
> thanks
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/GLpFbbHm0ogJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Best practice to handle this

2013-01-26 Thread Jim Ruther Nill
On Sat, Jan 26, 2013 at 8:58 PM, Linus Pettersson <
linus.petters...@gmail.com> wrote:

> Hi!
>
> I have a model which has a field that can have three values only. I store
> the value in the database as an integer, 0, 1 or 2, but when I display it I
> want a more appropriate text. And, I want it to be translatable using i18n.
>
> Let's say that it corresponds to how difficult something is. So, 0
> represents "Easy", 1 represents "Normal" and 2 represents "Hard".
> What I did was first to define it as a hash like this:
> DIFFICULTIES = { "Easy" => 0, "Normal" => 1, "Hard" => 2 }
> Then I can easily pass this to, for instance, simple_form and it will
> generate a nice dropdown with the correct values.
>
> But let's say that I have the value and want to display the text. Then I'd
> have to iterate over the hash to find which key corresponds to the right
> value. Right? Not that big of an issue when there are three values as in
> this example, but there could be more.
>

Use http://www.ruby-doc.org/core-1.9.3/Hash.html#method-i-key to get the
key you want
given a value.

I'm thinking that you will only do this if you have a small number of
constants that you want
to define.  If it is a long list, then use the database for that.


>
> How do you normally handle these cases? Is there any "best practice" to
> handle this in an efficient manner?
>
> Cheers,
> Linus
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/1fjJK_EjQ50J.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] group by + sum

2013-01-25 Thread Jim Ruther Nill
On Fri, Jan 25, 2013 at 9:42 PM, Werner wrote:

> Well.. I cant get it working
>
> Try to explain it again..
>
> db_table:
> week_id, project_id, user_id, hour
> ex. =>
> 33, 1, 1, 10
> 33, 4, 1, 20
> 33, 1, 2, 0
> 34, 1, 2, 15
> 34, 1, 1, 0
>
>
> So, user with the id 1 worked 10 hours in week 33 and 20 in the week 33,
> but other project
> I want to show all hours summed up per week per user
> row1(user1) => week 33 => 30, week 34 => 0
> row2(user2) => week 33 => 0, week 34 => 15
>
> Step one:
> I want one row per user, so I group:
> @hours = HourUser.all.group_by(&:user_id)
>
> view:
> @hours.each do |user, weeks|
>
> gives me each user in one 
> within this row, each week one cell
>
> <% weeks.group_by(&:week_id).each do |week, hours| %>
> <%= hours.map(&:hour).sum %>
>
> Shows the hours but not summed up. Instead I get :
> row 1 =>  ...10.. and does not stop the row but starts again with ... 20...
> row 2 =>  ...0 15
>

so this is your remaining problem right?  I think the hour column is
a string which results to a concat of the values instead of simple
addition.  try hours.map { |h| h.hour.to_f }.sum


>
> How to? Do I also have to group otherwise..?
> Thanks for support.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Am Donnerstag, 24. Januar 2013 16:01:06 UTC+1 schrieb jim:
>>
>>
>>
>>
>> On Thu, Jan 24, 2013 at 10:38 PM, Werner wrote:
>>
>>> Jim..sorry.. not my day...
>>> have to contemplate about your solution.
>>>
>>> I wonder..
>>>
>>> HourUser.includes(:user).**where.group_by { |h| h.week_id }
>>>
>>> <% @hours.keys.sort.each do |h| %>
>>>  <%= @hours[h].collect(&:hour).sum %>
>>> <% end %>
>>>
>>> is giving me what I want, just needs to be grouped by user_id
>>>
>>> Thanks so far.
>>>
>>
>> So given the current solution you have, you also want to group by user_id
>> right?
>> so here's how it should go.
>>
>> @hour_users = HourUser.all.group_by(&:week_**id)
>>
>> gives you a hash with week_ids as keys
>>
>> @hour_users.each do |week_id, by_week|
>>   by_week.group_by(&:user_id).**each do |user_id, hour_users|
>> hour_users.map(&:hour).sum
>>   end
>> end
>>
>> using my first suggestion
>>
>> @hour_users = HourUser.sum(:hour, group: [:week_id, :user_id])
>>
>> @hour_users.each do |(week_id, user_id), total_hours|
>>   # do something with week_id, user_id and total_hours
>> end
>>
>> Good luck!
>>
>>>
>>>
>>>
>>> Am Donnerstag, 24. Januar 2013 14:16:16 UTC+1 schrieb jim:




 On Thu, Jan 24, 2013 at 7:55 PM, Werner 
 wrote:

> Hi Jim.. thanks so far..
>
> in the moment this is a bit too far for me.
>
>
> Just remember that to get a certain value, you'll have to pass an
> array as the index
> ie sums[[33,2]] to get 70
> => this is unclear
> Pls. be so kind to explain the view part.
>

 since the keys of the hash is an array, you need to use an array as the
 index to get a value

 >> sums = { [33, 2] => 70, [34, 2] => 15, [35, 3] => 20 }
 >> sums[34,2]
 ArgumentError: wrong number of arguments (2 for 1)
 from (irb):3:in `[]'
 from (irb):3
 >> sums[[34,2]] # 15

 the keys are defined by the group option you passed to #sum, so if you
 pass as sql statement to
 the group option, you'll get that as key. ie (postgre)

 >> HourUser.sum(:hours, group: "week_id || ' --- ' || user_id", order:
 :user_id)
 >> { '33 --- 2' => 70, '34 --- 2' => 15, '35 --- 3' => 20 }

 hope this helps



>
> Werner
>
>
>
>
>
>
> Am Donnerstag, 24. Januar 2013 11:36:44 UTC+1 schrieb jim:
>>
>>
>>
>> On Thu, Jan 24, 2013 at 4:35 PM, Werner > > wrote:
>>
>>> Hi.. I need some support...
>>>
>>> table:
>>> week_id, user_id, project_id, hours
>>> ex. =>
>>> 33, 2, 1, 10
>>> 34, 2,1,15
>>> 33, 2, 2, 20
>>> 35, 3, 1,20
>>> etc.
>>
>>
>>> Want to display a sum of hours per week_id per user_id
>>> I have:
>>>
>>> @hours = HourUser.includes(:user).**group_by { |h| h.week_id }
>>>
>>> @hours.keys.sort.each do |hour|
>>> @hours[hour].collect(&:**stunden).sum
>>>
>>
>> Look at http://api.rubyonrails.org/**classes/ActiveRecord/**
>> Calculations.html#method-i-sum
>>
>> sums = HourUser.sum(:hours, group: [:week_id, :user_id], order:
>> :user_id)
>>
>> You'll end up with something like [33, 2] => 70, [34, 2] => 15, [35,
>> 3] => 20
>> Just remember that to get a certain value, you'll have to pass an
>> array as the index
>> ie sums[[33,2]] to get 70
>>
>>
>>
>>>
>>> Hours are summed up, but not sorted by user_id..
>>> How to get that?
>>>
>>> Thanks
>>> Werner
>>>
>>>
>>>
>>>
>>>
>>>  --
>>> You received this message because y

Re: [Rails] I am trying to add a block dynamically. I is giving an error saying “wrong no. of arguments”(1 for 2

2013-01-24 Thread Jim Ruther Nill
On Fri, Jan 25, 2013 at 3:47 PM, suchi gupta  wrote:

>   <%render :partial =>'new_campaign_partial'%>
>  
>
>  <%= link_to_function "Add a campaign" do |page|
> inser_html :bottom, :new_campaign, :partial=>'new_campaign_partial'
>end%>
>

If I remember correctly, link_to_function does not accept a block


>
>
>
> the partial is named new_campaign_partial.rhtml. It has just the html
> code for creating certain text fiels and calendar
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: Add Multiple Records of a model using single form

2013-01-24 Thread Jim Ruther Nill
On Thu, Jan 24, 2013 at 10:49 PM, BalaRaju Vankala
wrote:

> Thank you @Werner its Working.
>
>
> On Thu, Jan 24, 2013 at 7:59 PM, Werner 
> wrote:
>
>> something like that:
>>
>> *<% 1.upto(2) do |i| %>
>> <%= text_field_tag "fields[#{i}][user_name]",'', :class => "user_name" %>
>> <%= radio_button_tag "fields[#{i}][is_checked]", '1', false %>
>> <% end %>
>>
>> params[:fields].each do |i, values|
>> u = User.create(values)
>> end*
>
>
Just for clarification, you don't need to supply an index

<% 2.times do %>
  <%= text_field_tag "fields[][user_name]",'', :class => "user_name" %>
  <%= radio_button_tag "fields[][is_checked]", '1', false %>
<% end %>

should be enough :)

params[:fields] will be an array of attributes instead of a hash
so you can do User.create params[:fields] (I think :D)


>
>>
>>
>>
>> Am Donnerstag, 24. Januar 2013 14:33:45 UTC+1 schrieb BalaRaju Vankala:
>>
>>>
>>>
>>> hello all,
>>>
>>> I am working on a simple project on ruby on rails. I need to add a data
>>> to the database. I would like to add multiple records of a model using
>>> single form and single submit button so that all the records I entered in
>>> the form are inserted into database table. I need to design a form with
>>> multiple duplicate fields, each set of fields represent a database record.
>>> Thanks in Advance
>>> --
>>> --**--**
>>> --**--
>>> Thank You.
>>>
>>> Best Wishes,
>>>
>>> BalaRaju Vankala,
>>>
>>>   --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/rubyonrails-talk/-/O-UeEUuWFGoJ.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
>
> --
>
> 
> Thank You.
>
> Best Wishes,
>
> BalaRaju Vankala,
> 8886565300.
>
>
>  --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] group by + sum

2013-01-24 Thread Jim Ruther Nill
On Thu, Jan 24, 2013 at 10:38 PM, Werner wrote:

> Jim..sorry.. not my day...
> have to contemplate about your solution.
>
> I wonder..
>
> HourUser.includes(:user).where.group_by { |h| h.week_id }
>
> <% @hours.keys.sort.each do |h| %>
>  <%= @hours[h].collect(&:hour).sum %>
> <% end %>
>
> is giving me what I want, just needs to be grouped by user_id
>
> Thanks so far.
>

So given the current solution you have, you also want to group by user_id
right?
so here's how it should go.

@hour_users = HourUser.all.group_by(&:week_id)

gives you a hash with week_ids as keys

@hour_users.each do |week_id, by_week|
  by_week.group_by(&:user_id).each do |user_id, hour_users|
hour_users.map(&:hour).sum
  end
end

using my first suggestion

@hour_users = HourUser.sum(:hour, group: [:week_id, :user_id])

@hour_users.each do |(week_id, user_id), total_hours|
  # do something with week_id, user_id and total_hours
end

Good luck!

>
>
>
> Am Donnerstag, 24. Januar 2013 14:16:16 UTC+1 schrieb jim:
>>
>>
>>
>>
>> On Thu, Jan 24, 2013 at 7:55 PM, Werner wrote:
>>
>>> Hi Jim.. thanks so far..
>>>
>>> in the moment this is a bit too far for me.
>>>
>>>
>>> Just remember that to get a certain value, you'll have to pass an array
>>> as the index
>>> ie sums[[33,2]] to get 70
>>> => this is unclear
>>> Pls. be so kind to explain the view part.
>>>
>>
>> since the keys of the hash is an array, you need to use an array as the
>> index to get a value
>>
>> >> sums = { [33, 2] => 70, [34, 2] => 15, [35, 3] => 20 }
>> >> sums[34,2]
>> ArgumentError: wrong number of arguments (2 for 1)
>> from (irb):3:in `[]'
>> from (irb):3
>> >> sums[[34,2]] # 15
>>
>> the keys are defined by the group option you passed to #sum, so if you
>> pass as sql statement to
>> the group option, you'll get that as key. ie (postgre)
>>
>> >> HourUser.sum(:hours, group: "week_id || ' --- ' || user_id", order:
>> :user_id)
>> >> { '33 --- 2' => 70, '34 --- 2' => 15, '35 --- 3' => 20 }
>>
>> hope this helps
>>
>>
>>
>>>
>>> Werner
>>>
>>>
>>>
>>>
>>>
>>>
>>> Am Donnerstag, 24. Januar 2013 11:36:44 UTC+1 schrieb jim:



 On Thu, Jan 24, 2013 at 4:35 PM, Werner 
 wrote:

> Hi.. I need some support...
>
> table:
> week_id, user_id, project_id, hours
> ex. =>
> 33, 2, 1, 10
> 34, 2,1,15
> 33, 2, 2, 20
> 35, 3, 1,20
> etc.


> Want to display a sum of hours per week_id per user_id
> I have:
>
> @hours = HourUser.includes(:user).**group**_by { |h| h.week_id }
>
> @hours.keys.sort.each do |hour|
> @hours[hour].collect(&:**stunden**).sum
>

 Look at http://api.rubyonrails.org/classes/ActiveRecord/**Calculati
 **ons.html#method-i-sum

 sums = HourUser.sum(:hours, group: [:week_id, :user_id], order:
 :user_id)

 You'll end up with something like [33, 2] => 70, [34, 2] => 15, [35, 3]
 => 20
 Just remember that to get a certain value, you'll have to pass an array
 as the index
 ie sums[[33,2]] to get 70



>
> Hours are summed up, but not sorted by user_id..
> How to get that?
>
> Thanks
> Werner
>
>
>
>
>
>  --
> 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 rubyonra...@googlegroups.**com.
> To unsubscribe from this group, send email to rubyonrails-ta...@**
> googlegroups**.com.
>
> To view this discussion on the web visit https://groups.google.com/d/*
> *ms**g/rubyonrails-talk/-/**nIwEcQd5R**UMJ
> .
> For more options, visit 
> https://groups.google.com/**grou**ps/opt_out
> .
>
>
>



 --
 -----
 visit my blog at http://jimlabs.heroku.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 rubyonra...@googlegroups.**com.
>>> To unsubscribe from this group, send email to rubyonrails-ta...@**
>>> googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> msg/rubyonrails-talk/-/**CDisLJSEMNEJ
>>> .
>>>
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>> --**--**-
>> visit my blog at http://jimlabs.heroku.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 rub

Re: [Rails] group by + sum

2013-01-24 Thread Jim Ruther Nill
On Thu, Jan 24, 2013 at 7:55 PM, Werner wrote:

> Hi Jim.. thanks so far..
>
> in the moment this is a bit too far for me.
>
>
> Just remember that to get a certain value, you'll have to pass an array as
> the index
> ie sums[[33,2]] to get 70
> => this is unclear
> Pls. be so kind to explain the view part.
>

since the keys of the hash is an array, you need to use an array as the
index to get a value

>> sums = { [33, 2] => 70, [34, 2] => 15, [35, 3] => 20 }
>> sums[34,2]
ArgumentError: wrong number of arguments (2 for 1)
from (irb):3:in `[]'
from (irb):3
>> sums[[34,2]] # 15

the keys are defined by the group option you passed to #sum, so if you pass
as sql statement to
the group option, you'll get that as key. ie (postgre)

>> HourUser.sum(:hours, group: "week_id || ' --- ' || user_id", order:
:user_id)
>> { '33 --- 2' => 70, '34 --- 2' => 15, '35 --- 3' => 20 }

hope this helps



>
> Werner
>
>
>
>
>
>
> Am Donnerstag, 24. Januar 2013 11:36:44 UTC+1 schrieb jim:
>>
>>
>>
>> On Thu, Jan 24, 2013 at 4:35 PM, Werner wrote:
>>
>>> Hi.. I need some support...
>>>
>>> table:
>>> week_id, user_id, project_id, hours
>>> ex. =>
>>> 33, 2, 1, 10
>>> 34, 2,1,15
>>> 33, 2, 2, 20
>>> 35, 3, 1,20
>>> etc.
>>
>>
>>> Want to display a sum of hours per week_id per user_id
>>> I have:
>>>
>>> @hours = HourUser.includes(:user).**group_by { |h| h.week_id }
>>>
>>> @hours.keys.sort.each do |hour|
>>> @hours[hour].collect(&:**stunden).sum
>>>
>>
>> Look at http://api.rubyonrails.org/**classes/ActiveRecord/**
>> Calculations.html#method-i-sum
>>
>> sums = HourUser.sum(:hours, group: [:week_id, :user_id], order: :user_id)
>>
>> You'll end up with something like [33, 2] => 70, [34, 2] => 15, [35, 3]
>> => 20
>> Just remember that to get a certain value, you'll have to pass an array
>> as the index
>> ie sums[[33,2]] to get 70
>>
>>
>>
>>>
>>> Hours are summed up, but not sorted by user_id..
>>> How to get that?
>>>
>>> Thanks
>>> Werner
>>>
>>>
>>>
>>>
>>>
>>>  --
>>> 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 rubyonra...@googlegroups.**com.
>>> To unsubscribe from this group, send email to rubyonrails-ta...@**
>>> googlegroups.com.
>>>
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> msg/rubyonrails-talk/-/**nIwEcQd5RUMJ
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>> --**--**-
>> visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/CDisLJSEMNEJ.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] group by + sum

2013-01-24 Thread Jim Ruther Nill
On Thu, Jan 24, 2013 at 4:35 PM, Werner wrote:

> Hi.. I need some support...
>
> table:
> week_id, user_id, project_id, hours
> ex. =>
> 33, 2, 1, 10
> 34, 2,1,15
> 33, 2, 2, 20
> 35, 3, 1,20
> etc.


> Want to display a sum of hours per week_id per user_id
> I have:
>
> @hours = HourUser.includes(:user).group_by { |h| h.week_id }
>
> @hours.keys.sort.each do |hour|
> @hours[hour].collect(&:stunden).sum
>

Look at
http://api.rubyonrails.org/classes/ActiveRecord/Calculations.html#method-i-sum

sums = HourUser.sum(:hours, group: [:week_id, :user_id], order: :user_id)

You'll end up with something like [33, 2] => 70, [34, 2] => 15, [35, 3] =>
20
Just remember that to get a certain value, you'll have to pass an array as
the index
ie sums[[33,2]] to get 70



>
> Hours are summed up, but not sorted by user_id..
> How to get that?
>
> Thanks
> Werner
>
>
>
>
>
>  --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/nIwEcQd5RUMJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Newbie: I just want to exclude two attributes when I call update_attributes

2013-01-20 Thread Jim Ruther Nill
On Mon, Jan 21, 2013 at 2:50 AM, Dheeraj Kumar wrote:

> You still haven't shown us what's in params[:foo] and the exact error you
> get.
>
> --
> Dheeraj Kumar
>
> On Monday 21 January 2013 at 12:07 AM, Don Schenck wrote:
>
>
> And in the Create method as well.
>
> This FEELS wrong, but it works.
>
> You may want to look at strong_parameters
https://github.com/rails/strong_parameters


>
>
> On Saturday, January 19, 2013 10:44:21 AM UTC-5, Don Schenck wrote:
>
> Colin --
>
> I ended up using
>
>
> .slice(:field1, :field2, :field4)
>
>
> in my update. Works fine.
>
> -- Don
>
>
>
> On Saturday, January 19, 2013 4:17:26 AM UTC-5, Colin Law wrote:
>
> On 18 January 2013 21:44, Don Schenck  wrote:
> > I have two virtual attributes in my model. Let's call them
> "hours_worked"
> > and "minutes_worked".
> >
> > I use them to calculate "work_time", which is an integer I store -- it's
> the
> > total minutes worked (e.g. 3.5 hours is 210).
> >
> > I want :hours_worked and :minutes_worked to NEVER appear in the
> database.
> >
> > But when @foo.update_attributes(params[**:foo]) is called, it bombs.
>
> What do you mean it bombs?  Show us what is in params[:foo] and the
> error you get.
>
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/JEc4oPvWtiUJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
>  --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Setting image

2013-01-17 Thread Jim Ruther Nill
On Thu, Jan 17, 2013 at 9:52 PM, Avi  wrote:

> The requirement is:-
>
> When we click on the button to choose the file, after choosing, the image
> should be shown in the ui in IFRAME or something.
>
Not sure how to do that...
>

this is a shameless plug but you can look at my blog if you need help in
doing this

http://jimlabs.heroku.com/posts/multiple-image-upload-with-preview-using-ajax-and-jquery


>
> On Thursday, January 17, 2013 7:08:05 PM UTC+5:30, jim wrote:
>>
>>
>>
>>
>> On Thu, Jan 17, 2013 at 6:27 PM, Avi  wrote:
>>
>>> Hello All,
>>>
>>> I am uploading an image from disc. While choosing the image I want to
>>> show that image on the UI.
>>> How can I do that?
>>> I am using paperclip gem.
>>>
>>
>> before html5, i think this is not possible since javascript shouldn't
>> have access to your
>> file system.  what you can do is upload the image first then show a
>> preview after.
>>
>>
>>>
>>> Thanks,
>>> Avi
>>>
>>> --
>>> 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 rubyonra...@googlegroups.**com.
>>> To unsubscribe from this group, send email to rubyonrails-ta...@**
>>> googlegroups.com.
>>>
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> msg/rubyonrails-talk/-/**6hjaYq708PUJ
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>> --**--**-
>> visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/YeagrIa8ncgJ.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Setting image

2013-01-17 Thread Jim Ruther Nill
On Thu, Jan 17, 2013 at 6:27 PM, Avi  wrote:

> Hello All,
>
> I am uploading an image from disc. While choosing the image I want to show
> that image on the UI.
> How can I do that?
> I am using paperclip gem.
>

before html5, i think this is not possible since javascript shouldn't have
access to your
file system.  what you can do is upload the image first then show a preview
after.


>
> Thanks,
> Avi
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/6hjaYq708PUJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Drag & drop

2013-01-15 Thread Jim Ruther Nill
On Wed, Jan 16, 2013 at 2:32 PM, Avi  wrote:

> Hello All,
>
> Is there any gem which provides drag & drop facility in rails 3.2.8?
> I want to show data in grid view. & I want to drag & drop & change the
> positions of those..
> Any suggestions ?
>

look at jquery ui draggable, droppable and sortable

http://jqueryui.com/draggable/


>
>
> Thanks, Avi
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/iHmgRrXjG8QJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: Nested models in a form

2013-01-13 Thread Jim Ruther Nill
On Mon, Jan 14, 2013 at 5:15 AM, Rafael C. de Almeida
wrote:

> Let me send you another post the intention of documenting this issue for
> people from the future. The solution I'm going with for now is:
> substituting "???" for lf.object_name+"[service_ids][]". It may not be too
> pretty, but it works (don't forget setting :service_ids in attr_accessible
> and accept_nested_attributes_for :services).


just a reminder that you may want to test your solution for creating new
records
and for editing existing ones if you're using the same partial/template for
both
pages (although I think it looks like it's going to work except for the
scenario that
you try to edit and remove all services for a particular lawyer).  also,
you don't need
accepts_nested_attributes_for :services if you are using service_ids.


>
>
> On Sunday, January 13, 2013 7:00:55 PM UTC-2, Rafael C. de Almeida wrote:
>>
>> I have found out that user[lawyers_attributes][**0][service_ids][] works
>> for the first lawyer (I update 0 to 1 for the second and so on). However,
>> that seems rather ugly. Is thera a way to extract the path
>> user[lawyers_attributes][0] from lf object?
>>
>> On Sunday, January 13, 2013 4:06:21 PM UTC-2, Rafael C. de Almeida wrote:
>>>
>>> Hello,
>>>
>>> I'm trying to work with nested models in a form view and it's not going
>>> so smoothly. A user has many lawyers and a lawyer can take many
>>> services. I want a checkbox on which the user can select the services of
>>> each lawyer. How can I do it? This is what I've got so far:
>>>
>>> <%= form_for @user do |f| %>
>>>
>>>   <%= f.label :email %><%= f.email_field :email %>
>>>
>>>   
>>>
>>>   <% @user.lawyers.each do |lawyer| %>
>>>
>>> <%= f.fields_for :lawyers, lawyer do |lf| %>
>>>
>>>   <%= lf.label :name, "Nome: " %><%= lf.text_field :name %>
>>>
>>>   
>>>
>>>   <% Service.all.each do |service| %>
>>>
>>> <%= check_box_tag ???, service.id, 
>>> lawyer.services.include?(**service) %>
>>>
>>>   <% end %>
>>>
>>> <% end %>
>>>
>>>   <% end %>
>>>
>>> <% end %>
>>>
>>>  --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/UVMKaTGdiJEJ.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Good books about the internals of Rails 3

2013-01-10 Thread Jim Ruther Nill
On Thu, Jan 10, 2013 at 10:50 PM, Maciej Rząsa wrote:

> @Norbert Thanks for the constructive answer! I'm glad you noticed that
> there is no difference between using two-year-old PC and two-year-outdated
> web framework!
>
> More seriously: changes between RoR2 and RoR3 were quite significant, so
> buying a book about RoR2 internals to use it with Rails3 was rather a bad
> idea. I'm trying to learn if it's the same in this case.
>

I suggest you weigh at the pros and cons.  If you can wait for a couple of
months for the release of rails 4
and another or 2 for a good book, then I'd say wait.  But in those months,
you could've already acquired a
good deal of knowledge when you buy a rails 3 book.  There are some new
stuff going out in rails 4 like
turbolinks, doll caching and strong parameters, all of which are kind of an
upgrade to the version that rails
3 is using so you might want to look at how those work at the moment while
waiting for rails 4.


>
>
> 2013/1/10 Norbert Melzer 
>
>>
>>
>>
>> 2013/1/10 Maciej Rząsa 
>>
>>> Do you think it's still reasonable to buy those books, knowing that RoR4
>>> will be released soon? I'm especially interested in Crafting Rails
>>> Applications, but I don't want to buy something that will be obsolete in a
>>> couple of months.
>>>
>>> Why did you buy a PC?
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] CSRF resets my session in Firefox

2013-01-09 Thread Jim Ruther Nill
On Thu, Jan 10, 2013 at 4:18 AM, Jeff Miller  wrote:

> Hello all,
>   I've been trying to diagnose an issue with CSRF and Firefox
> specifically. I've got an ajax based form, using UJS (yes, I have
> csrf_meta_tag in my layout and I've tried adding the X-CSRF-Token header
> to the ajax beforeSend events without any luck)...


Instead of sending it as part of the header, have you tried sending it as
part of the data?  I'm not sure if it will make any difference (it should
not)
but it won't hurt to try.



> The form just posts
> some data to an ajax method that creates, saves, and sets the session
> for a shopper as well as for a hit object, then returns some JSON. This
> works in Chrome and Safari (haven't tested IE yet), but Firefox is a
> no-go. Basically, the session gets reset by CSRF (I confirmed this by
> setting config.action_controller.allow_forgery_protection to false and
> it works), but the weird thing is that upon inspecting the session, I DO
> have a hit_id, but no shopper_id!! This completely breaks my form and is
> frustrating as hell :P
>
> I'm running on Rails 3.2.11 and Ruby 1.9.3p327. Any and all help would
> be appreciated!
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Need User All login and logout times

2013-01-01 Thread Jim Ruther Nill
On Wed, Jan 2, 2013 at 3:44 PM, Saravanan P wrote:

> May be if your open private window and signin.
> Then without signout, the user close browser my code (i.e "after sign out"
> method) will not run and i cant get sign out time... thats why i said...
>

you can get around this by using javascript and ajax.  Look at before
https://developer.mozilla.org/en-US/docs/DOM/window.onbeforeunload


>
>
> On Wed, Jan 2, 2013 at 12:50 PM, Dheeraj Kumar 
> wrote:
>
>> Why don't you think its a good way?
>>
>> --
>> Dheeraj Kumar
>>
>> On Wednesday 2 January 2013 at 12:45 PM, Saravanan P wrote:
>>
>> Hi Dheeraj
>>
>> Thanks for reply.
>> In Trackable, i can only see total sign in count, last sign in time and
>> sign out time...
>> But I need, users all sign in and sign out time stamp.
>>  Is there any way?
>>
>> I can implement this by adding records in separate table by devise "after
>> sign in" and "after sign out" method. But i think its not good idea to get
>> that.
>>
>>
>>
>>
>> On Wed, Jan 2, 2013 at 12:37 PM, Dheeraj Kumar > > wrote:
>>
>>
>> http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Trackable
>>
>> --
>> Dheeraj Kumar
>>
>> On Wednesday 2 January 2013 at 12:16 PM, Saravanan P wrote:
>>
>> Hello everyone,
>>
>> I need user *All login* and* logout time*. not only last login and
>> logout time.
>> I am using rails 3.2.8 + devise gem for User.
>>
>> Is there any way to get all time?
>>
>> Saravanan.
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/rubyonrails-talk/-/Fc-UcJCoDm4J.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>>
>>  --
>> 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+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>>
>>
>>
>> --
>> Regards by
>> Saravanan.P
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>>
>>  --
>> 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+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
>
> --
> Regards by
> Saravanan.P
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Need User All login and logout times

2013-01-01 Thread Jim Ruther Nill
On Wed, Jan 2, 2013 at 3:20 PM, Dheeraj Kumar wrote:

> Why don't you think its a good way?
>
> --
> Dheeraj Kumar
>
> On Wednesday 2 January 2013 at 12:45 PM, Saravanan P wrote:
>
> Hi Dheeraj
>
> Thanks for reply.
> In Trackable, i can only see total sign in count, last sign in time and
> sign out time...
> But I need, users all sign in and sign out time stamp.
> Is there any way?
>
> For past logins and logouts, there's no other way to get it other than
parsing the log files.
But I think that's no easy task plus you usually don't have info on who
logged in and out
in the logs so that may also be impossible.


> I can implement this by adding records in separate table by devise "after
> sign in" and "after sign out" method. But i think its not good idea to get
> that.
>
> this is probably the best way to get what you want

Good luck!

>
>
>
>
> On Wed, Jan 2, 2013 at 12:37 PM, Dheeraj Kumar 
> wrote:
>
>
> http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Trackable
>
> --
> Dheeraj Kumar
>
> On Wednesday 2 January 2013 at 12:16 PM, Saravanan P wrote:
>
> Hello everyone,
>
> I need user *All login* and* logout time*. not only last login and logout
> time.
> I am using rails 3.2.8 + devise gem for User.
>
> Is there any way to get all time?
>
> Saravanan.
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/Fc-UcJCoDm4J.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
>  --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
>
>
> --
> Regards by
> Saravanan.P
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
>  --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Passing parameter from a dropdown.

2012-12-21 Thread Jim Ruther Nill


Sent from my iPhone

On 21/12/2012, at 8:32 PM, Avi  wrote:

> Somehow I did manage to pass the parameter from the dropdown to controller.
> But the problem is here - I am getting it as string.
> 
> In Controller:
> 
> class ReportController < ApplicationController
>   
>   REPORT1 = "type =?", "Box"
>   REPORT2 = "action = ? and type =?", "create", "Square"
> 
> 
>  def report
>param = params[:audit_report] // How to convert this string to an object 
> or static variable ? Or what is the best way to do it ?
>@report_data  = 
> (Audited::Adapters::ActiveRecord::Audit.where(param))
> // If I am passing this param, it comes as a string not as static varaible in 
> this controller.
>  end
> 
> end
> 
> In View :
> 
> 
> function audit_options(selected_audit){
>   jQuery("#reports").load("/audit_report/report?audit_report=" + 
> selected_audit);  
> }
> 
> 
> <%= select_tag "reports_name", options_for_select([["User1", "REPORT1"], 
> ["User2", "REPORT2"]]), :onchange =>"audit_options(this.value)" %>
> 
> 
>   
>   

You should read on action controller basics. And also on debugging using pry or 
debugger so you can experiment on what you want to achieve. Good luck!

> 
> 
> ---
> 
> On Friday, December 21, 2012 12:19:19 PM UTC+5:30, jim wrote:
>> 
>> 
>> 
>> 
>> On Fri, Dec 21, 2012 at 2:46 PM, Avi  wrote:
>>> Sorry for late reply...
>>> 
>>> Can't we pass the param through ajax or js ?
>> 
>> yes you can. you have to read on ajax.
>>  
>>> 
>>> 
>>> On Thursday, December 20, 2012 11:50:37 AM UTC+5:30, jim wrote:
 
 
 
 
 On Thu, Dec 20, 2012 at 1:45 PM, Avi  wrote:
> I am not adding any form because there is no model for this page. 
> Only there is controller and view.
 
 you need to add a form to pass the selected values to the controller.  It 
 doesn't
 matter whether you're accessing a model or not.
  
> 
> On Thursday, December 20, 2012 11:11:29 AM UTC+5:30, jim wrote:
>> 
>> 
>> 
>> 
>> On Thu, Dec 20, 2012 at 12:53 PM, Avi  wrote:
>>> Hello,
>>> 
>>> I have a dropdown in the UI. There are many oprions.
>>> How do I send the parameter from the dropdown - the selected value to 
>>> the controller?
>>> 
>>> I have tried :-
>>> 
>>> 1. <%= select_tag 'name', options_for_select(@list, :selected) %>
>>> 2. <%= select("audit", "value",options_for_select([["User 
>>> Registration", "USER_REGISTRATION"], ["Download", "USER_REPORT"]], 
>>> :selected => params[:value]) %>
>>> 
>>> I am not getting any parameters passed to the controller.
>> 
>> make sure that the select tag above is part of the form you are 
>> submitting and that you
>> are actually submitting to the right action.  A quick look on your code 
>> raised no issues.
>>  
>>> 
>>> -- 
>>> 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 rubyonra...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> rubyonrails-ta...@googlegroups.com.
>>> 
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msg/rubyonrails-talk/-/fk7PY0E_DrMJ.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>> 
>> 
>> 
>> 
>> -- 
>> -
>> visit my blog at http://jimlabs.heroku.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 rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-ta...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/rubyonrails-talk/-/ezhDSMxW09AJ.
> 
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
 
 
 
 
 -- 
 -
 visit my blog at http://jimlabs.heroku.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 rubyonra...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> rubyonrails-ta...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msg/rubyonrails-talk/-/KHhmZn0tpCEJ.
>>> 
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>> 
>> 
>> 
>> -- 
>> -
>> visit my blog at http://jimlabs.heroku.com
> 
> -- 
> You received this message because you are 

Re: [Rails] Disable back button of browser

2012-12-20 Thread Jim Ruther Nill
On Fri, Dec 21, 2012 at 3:10 PM, Ashokkumar Yuvarajan <
ashokku...@shriramits.com> wrote:

> Thanks!
>
> Is there any another way??
>

Nope.


>
> My requirement is, once i clicks the browser back button my site *redirect
> to home page*.
>
> Please advice!
>

If there is a way, this is not the forum to ask :)


>
>
>
> On Fri, Dec 21, 2012 at 12:05 PM, Jordon Bedwell wrote:
>
>> On Fri, Dec 21, 2012 at 12:32 AM, Maddy 
>> wrote:
>> > How to disable back button of browser??
>>
>> You can't.  It's the users browser, not yours.
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
> --
>
> *"Attitude is a little thing that makes a big difference"*
>
>
> Thanks & Regards
> *Ashokkumar.Y*
> *ROR-Developer
> **email : ashokku...@shriramits.com*
> *Shriramits*
>
>
> *
> *
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Passing parameter from a dropdown.

2012-12-20 Thread Jim Ruther Nill
On Fri, Dec 21, 2012 at 2:46 PM, Avi  wrote:

> Sorry for late reply...
>
> Can't we pass the param through ajax or js ?
>

yes you can. you have to read on ajax.


>
>
> On Thursday, December 20, 2012 11:50:37 AM UTC+5:30, jim wrote:
>>
>>
>>
>>
>> On Thu, Dec 20, 2012 at 1:45 PM, Avi  wrote:
>>
>>> I am not adding any form because there is no model for this page.
>>> Only there is controller and view.
>>>
>>
>> you need to add a form to pass the selected values to the controller.  It
>> doesn't
>> matter whether you're accessing a model or not.
>>
>>
>>>
>>> On Thursday, December 20, 2012 11:11:29 AM UTC+5:30, jim wrote:




 On Thu, Dec 20, 2012 at 12:53 PM, Avi  wrote:

> Hello,
>
> I have a dropdown in the UI. There are many oprions.
> How do I send the parameter from the dropdown - the selected value to
> the controller?
>
> I have tried :-
>
> 1. <%= select_tag 'name', options_for_select(@list, :selected) %>
> 2. <%= select("audit", "value",options_for_select([["User
> Registration", "USER_REGISTRATION"], ["Download", "USER_REPORT"]],
> :selected => params[:value]) %>
>
> I am not getting any parameters passed to the controller.
>

 make sure that the select tag above is part of the form you are
 submitting and that you
 are actually submitting to the right action.  A quick look on your code
 raised no issues.


>
>
> --
> 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 rubyonra...@googlegroups.**com.
> To unsubscribe from this group, send email to rubyonrails-ta...@**
> googlegroups**.com.
>
> To view this discussion on the web visit https://groups.google.com/d/*
> *ms**g/rubyonrails-talk/-/**fk7PY0E_**DrMJ
> .
> For more options, visit 
> https://groups.google.com/**grou**ps/opt_out
> .
>
>
>



 --
 -----
 visit my blog at http://jimlabs.heroku.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 rubyonra...@googlegroups.**com.
>>> To unsubscribe from this group, send email to rubyonrails-ta...@**
>>> googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> msg/rubyonrails-talk/-/**ezhDSMxW09AJ
>>> .
>>>
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>> --**--**-
>> visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/KHhmZn0tpCEJ.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Disable back button of browser

2012-12-20 Thread Jim Ruther Nill
On Fri, Dec 21, 2012 at 2:32 PM, Maddy  wrote:

> Hi Folks,
>
> Good Day,
>
> *How to disable back button of browser??*
>

you cant.


>
> Please advise!
>
> Thank You.
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/t_Pf7lwKLwAJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] two things seem to equal, but the UNLESS statement passes anyway.

2012-12-20 Thread Jim Ruther Nill
On Thu, Dec 20, 2012 at 6:58 PM, Jim Ruther Nill  wrote:

>
>
>
> On Thu, Dec 20, 2012 at 6:47 PM, Binny Zupnick wrote:
>
>> when params[:which_post] happens to equal the users last message, the
>> UNLESS staement on line 11 passes when in fact they both equal. I've
>> done testing and I know the params work and they do in fact equal each
>> other, but it still passes when it shouldn't.
>>
>
> nothing that is passed as a params will be typecasted as an integer so you
> may need
> to apply a .to_s to @message.id or .to_i to params[:which_post]
>

just a follow up, it is better to assign the records to an instance
variable in the controller.
something like

# setup which_post here
@messages = @user.messages.where('messages.id != ?', which_post)

and then just use @messages on the view


>
>
>>
>> Attachments:
>> http://www.ruby-forum.com/attachment/7986/code.txt
>>
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
> --
> -
> visit my blog at http://jimlabs.heroku.com
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] two things seem to equal, but the UNLESS statement passes anyway.

2012-12-20 Thread Jim Ruther Nill
On Thu, Dec 20, 2012 at 6:47 PM, Binny Zupnick  wrote:

> when params[:which_post] happens to equal the users last message, the
> UNLESS staement on line 11 passes when in fact they both equal. I've
> done testing and I know the params work and they do in fact equal each
> other, but it still passes when it shouldn't.
>

nothing that is passed as a params will be typecasted as an integer so you
may need
to apply a .to_s to @message.id or .to_i to params[:which_post]


>
> Attachments:
> http://www.ruby-forum.com/attachment/7986/code.txt
>
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Passing parameter from a dropdown.

2012-12-19 Thread Jim Ruther Nill
On Thu, Dec 20, 2012 at 1:45 PM, Avi  wrote:

> I am not adding any form because there is no model for this page.
> Only there is controller and view.
>

you need to add a form to pass the selected values to the controller.  It
doesn't
matter whether you're accessing a model or not.


>
> On Thursday, December 20, 2012 11:11:29 AM UTC+5:30, jim wrote:
>>
>>
>>
>>
>> On Thu, Dec 20, 2012 at 12:53 PM, Avi  wrote:
>>
>>> Hello,
>>>
>>> I have a dropdown in the UI. There are many oprions.
>>> How do I send the parameter from the dropdown - the selected value to
>>> the controller?
>>>
>>> I have tried :-
>>>
>>> 1. <%= select_tag 'name', options_for_select(@list, :selected) %>
>>> 2. <%= select("audit", "value",options_for_select([["**User
>>> Registration", "USER_REGISTRATION"], ["Download", "USER_REPORT"]],
>>> :selected => params[:value]) %>
>>>
>>> I am not getting any parameters passed to the controller.
>>>
>>
>> make sure that the select tag above is part of the form you are
>> submitting and that you
>> are actually submitting to the right action.  A quick look on your code
>> raised no issues.
>>
>>
>>>
>>>
>>> --
>>> 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 rubyonra...@googlegroups.**com.
>>> To unsubscribe from this group, send email to rubyonrails-ta...@**
>>> googlegroups.com.
>>>
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> msg/rubyonrails-talk/-/**fk7PY0E_DrMJ
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>> --**--**-
>> visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/ezhDSMxW09AJ.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Passing parameter from a dropdown.

2012-12-19 Thread Jim Ruther Nill
On Thu, Dec 20, 2012 at 12:53 PM, Avi  wrote:

> Hello,
>
> I have a dropdown in the UI. There are many oprions.
> How do I send the parameter from the dropdown - the selected value to the
> controller?
>
> I have tried :-
>
> 1. <%= select_tag 'name', options_for_select(@list, :selected) %>
> 2. <%= select("audit", "value",options_for_select([["User Registration",
> "USER_REGISTRATION"], ["Download", "USER_REPORT"]], :selected =>
> params[:value]) %>
>
> I am not getting any parameters passed to the controller.
>

make sure that the select tag above is part of the form you are submitting
and that you
are actually submitting to the right action.  A quick look on your code
raised no issues.


>
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/fk7PY0E_DrMJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] callbacks

2012-12-17 Thread Jim Ruther Nill
On Mon, Dec 17, 2012 at 10:15 PM, Avi  wrote:

> Hello All,
>
> I have two tables:
> user has_many room
> room belongs_to user
>
> When a new user is created, I want to save the room through some default
> values at the same time.
> How to do this by using callbacks?
>

> after_save or after_create ?
> & I want to use blocks with callbacks.
>

I'm assuming that a room is unique to a user and you want to create a room
everytime a user is created
so you need to use the after_create callback.  as for using the syntax to
use blocks in a callback, you can
look at http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html


>
> Any suggestions??
>
>
> Thanks,
> Avi
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/UrFJjpp9RX4J.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] save 2 value in diffrent field in one field at database

2012-12-16 Thread Jim Ruther Nill


Sent from my iPhone

On 16/12/2012, at 11:53 AM, Mas Bejo  wrote:

> i want to get value from 2 diffrent field, first
> from text_field, and second from select_date, and i want to save it in
> one field "TTL" in database, this is the syntax,
> i change my model file to be like this:
> 
> class Anggotum < ActiveRecord::Base
>  set_table_name "anggota"
>  attr_accessible :NP, :Nama, :Alamat, :TTL, :Telp, :Email, :Password,
> :Waktu_Daftar, :Posisi, :Jenis_Kelamin
>  attr_accessor   :tempat, :tanggal, :as=> :TTL
> end
> 
> and in my form.html.rb that connect to new.html.rb i add this syntax
> 
> 
><%= f.label :ttl %>
><%= f.label :":" %>
><%= f.text_field :tempat %>
>
>  
><%= select_date :tanggal %>
>  
> 
> but it make this error
> {:as=>:TTL} is not a symbol
> 
> can you help me?

I told you to read on virtual attributes and callbacks.  To give you a clue on 
what you need to do, you need to create 2 virtual atteibutes: one for the text 
field and one for the date select. Then use a before validation callback to 
concatenate them. Or just as colin suggested, concatenate them in the 
controller but i'd like to so these things in the model.

> 
> -- 
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: Combo Box in rails and save 2 value in diffrent field in one field at database

2012-12-15 Thread Jim Ruther Nill
On Sat, Dec 15, 2012 at 8:34 PM, Mas Bejo  wrote:

> i get this syntax
>
> <%=select_tag :Status, options_for_select(%w{ Perempuan Laki-Laki
> })%>
>
> but, i didn't work, i just need to get value from that combobox, and
> send it to query insert to field "Status" in database, but when i try

rails look it like null value
>

Sorry Mas, I still don't get what you want.


>
> 
>
> and for second problem, i get this syntax.
>
> 
> <%= f.label :ttl %>
> <%= f.label :":" %>
> <%= f.text_field :TTL %>
> 
>   
> <%= select_date %>
>   
>
> i want to concate value from "<%= f.text_field :TTL %>" and value from
> "<%= select_date %>" and send it to update field TTL in database
>

Have you read on callbacks and virtual attributes?


>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Combo Box in rails and save 2 value in diffrent field in one field at database

2012-12-14 Thread Jim Ruther Nill
On Sat, Dec 15, 2012 at 12:24 PM, Mas Bejo  wrote:

> i have problem to make combobox in rails can you help me.
> i try this syntax
> <%= f.select(:Status) %>
>
> Status is my field in database that have 2 value "perempuan" and
> "laki-laki". but i always got error in my rails
>

i don't understand your requirement for this one. so please clarify :)


>
>
> and the second problem i want to get value from 2 diffrent field, first
> from text_field, and second from select_date, and i want to save it in
> one field "TTL" in database, this is the syntax,
>
> 
> <%= f.label :ttl %>
> <%= f.label :":" %>
> <%= f.text_field :TTL %>
> 
>   
> <%= select_date %>
>   
>
> i confuse, how to get select_date value and concat it with value form
> text_field, and then save it in field "TTL" in database.
>

you need to use virtual attributes and callbacks to achieve this.  Read on
attr_accessor
and http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html


>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] has_many :through

2012-12-14 Thread Jim Ruther Nill
On Sat, Dec 15, 2012 at 7:48 AM, Jean  wrote:

> I'm new in rails and I've some doubts about what kind of relationship do I
> have to use. Here the case.
>
> I have two models Offer and User, a user could apply to many offers and
> offers can have many user also the users create the offers.
>
> I think I have to use a has_many :through ralationship. for example I
> create another model "Applicant", applicant belongs_to user and belongs_to
> offer. But how is the relationship from the user and offer model? for
> example
>
> User Model
>
>  has_many :offer, :through => :applicant
>
> Offer Model
>
>  has_many :user, :through => :applicant
>
> My doubt is because I already have this two relationship
>
> User Model
>
> has_many :offers, :dependent => :destroy
>
> Offer Model
>
> belongs_to :user
>
> After solve this doubt, I guest I have to save the record in the applicant
> model from the applicanst_controller, right?
>
since you have the applicant model as the join table between offer and
user, you won't
need the user_id column on offer.

User Model

has_many :applicants
has_many :offers, through: applicants

Offer Model

has_many :applicants
has_many :users, through: :applicants

It doesn't matter where you save from.  But it would be more logical
to create the user first before the offer.  Or if the offer already exists,
create the user first, then the applicant.

One more thing, it may be confusing to use the model applicant.  I think
you need to change to some other name like application or user_offer
which may make the associations more readable.



> Thanks in advance
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/PlDKDwbd0rEJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: make rails connect with database

2012-12-14 Thread Jim Ruther Nill
On Fri, Dec 14, 2012 at 6:16 PM, Mas Bejo  wrote:

> owh, i see.. i forgot that command. i have been try that command in
> other app (but when i create database via rails), but i forgot to try
> this command in this app.
>
>
> so, this the step, i try to run this:
>
> "rails console"
>
> and then i run this command:
>
> "Anggotum.all"
>
> it can show all of my record in table.
>

congrats! you're able to connect to the database.  if you have
other errors, please open a new thread about it :)


>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: make rails connect with database

2012-12-13 Thread Jim Ruther Nill
On Fri, Dec 14, 2012 at 2:10 PM, Mas Bejo  wrote:

> i didn't understand your instruction. what must i run in console? did
> you mean "rails server"? or  what else?
>

i mean rails console.
http://guides.rubyonrails.org/command_line.html#rails-console
you really need to go through a tutorial first and learn the basics of
rails.  I suggest
looking at the rails guide for starters.


>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: make rails connect with database

2012-12-13 Thread Jim Ruther Nill
On Fri, Dec 14, 2012 at 11:41 AM, Mas Bejo  wrote:

> 1.  Rails new First_app
> 2.  Change config database.yml
> 3.  Rake db:schema:dump
> 4.  Rails g scaffold Anggota –migration false
> 5.  Change First_app\app\model\anggotum.rb  with this syntax
>
> -
> class Anggotum < ActiveRecord::Base
>   set_table_name "anggota"
> end
> ---
>
> i have try to make new rails app, and that is the step by step that i
> did.
> did i do wrong step??
>

everything looks ok.  did you try it on the console?


>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: make rails connect with database

2012-12-13 Thread Jim Ruther Nill
On Fri, Dec 14, 2012 at 10:24 AM, Mas Bejo  wrote:

> no, i didn't use member table, i use member word just to describe to you
> singular and plural form. because i little confuse tell you plural form
> from word "anggota"
>

ok.  Just make sure that you're using the table name on the db on the
Anggota
model.  If you're doing that and still gets errors, I don't know what your
issue is.
I can't see any errors on your controller.  It seems like it's the one
generated by
the scaffold generator so there shouldn't be any errors in there.

Try running the console and see if Anggota.first retrieves the first record.


>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: make rails connect with database

2012-12-13 Thread Jim Ruther Nill
On Fri, Dec 14, 2012 at 10:14 AM, Mas Bejo  wrote:

> class AnggotaController < ApplicationController
>   # GET /anggota
>   # GET /anggota.json
>   def index
> @anggota = Anggotum.all
>
> respond_to do |format|
>   format.html # index.html.erb
>   format.json { render json: @anggota }
> end
>   end
>
>   # GET /anggota/1
>   # GET /anggota/1.json
>   def show
> @anggotum = Anggotum.find(params[:id])
>
> respond_to do |format|
>   format.html # show.html.erb
>   format.json { render json: @anggotum }
> end
>   end
>
>   # GET /anggota/new
>   # GET /anggota/new.json
>   def new
> @anggotum = Anggotum.new
>
> respond_to do |format|
>   format.html # new.html.erb
>   format.json { render json: @anggotum }
> end
>   end
>
>   # GET /anggota/1/edit
>   def edit
> @anggotum = Anggotum.find(params[:id])
>   end
>
>   # POST /anggota
>   # POST /anggota.json
>   def create
> @anggotum = Anggotum.new(params[:anggotum])
>
> respond_to do |format|
>   if @anggotum.save
> format.html { redirect_to @anggotum, notice: 'Anggotum was
> successfully created.' }
> format.json { render json: @anggotum, status: :created,
> location: @anggotum }
>   else
> format.html { render action: "new" }
> format.json { render json: @anggotum.errors, status:
> :unprocessable_entity }
>   end
> end
>   end
>
>   # PUT /anggota/1
>   # PUT /anggota/1.json
>   def update
> @anggotum = Anggotum.find(params[:id])
>
> respond_to do |format|
>   if @anggotum.update_attributes(params[:anggotum])
> format.html { redirect_to @anggotum, notice: 'Anggotum was
> successfully updated.' }
> format.json { head :no_content }
>   else
> format.html { render action: "edit" }
> format.json { render json: @anggotum.errors, status:
> :unprocessable_entity }
>   end
> end
>   end
>
>   # DELETE /anggota/1
>   # DELETE /anggota/1.json
>   def destroy
> @anggotum = Anggotum.find(params[:id])
> @anggotum.destroy
>
> respond_to do |format|
>   format.html { redirect_to anggota_url }
>   format.json { head :no_content }
> end
>   end
> end
>
> -
>
> that the code of anggota_controller.rb
> -
>

Where do you use the member table?  I think you need to read on the MVC
architecture first before you start working on this one.  I really can't
help you
if you have no firsthand knowledge of how the models and controllers are
connected.


>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: make rails connect with database

2012-12-13 Thread Jim Ruther Nill
On Fri, Dec 14, 2012 at 9:58 AM, Mas Bejo  wrote:

> i try to add this syntax
>
> set_table_name "member"
>
> in member.rb at folder app\models\
>
> but same as before it can't show record in table member, and i try to
> click new member, i saw this error
>
> "ActiveRecord::StatementInvalid in MemberController#create"
>
> and this error
>
> app/controllers/anggota_controller.rb:46:in `block in create'
> app/controllers/anggota_controller.rb:45:in `create'
>

can you post your code on anggota_controller?


>
> can you help me??
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: make rails connect with database

2012-12-13 Thread Jim Ruther Nill
On Fri, Dec 14, 2012 at 9:33 AM, Mas Bejo  wrote:

> did you mean add this syntax
>
>   set_table_name "member"
>
> in app\models\member.rb??
>
> i have been try it, but it didn't work..
>

well just saying it didn't work won't help you at all.  describe what
happens and why
you concluded it didn't 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 post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: make rails connect with database

2012-12-13 Thread Jim Ruther Nill
On Thu, Dec 13, 2012 at 11:22 PM, Mas Bejo  wrote:

> I always see, every table in rails given the name of the plural form.
> however I have a table with a singular form. let say my table name
> "member" not "members", could this create problems?
> then the rails command writing table name usually begins with a capital
> letter and using the singular form. Can I have a table named in the
> singular form, and run the command with the same name?
>
> I have tried, but it can not display the contents of my database. there
> are things that make me confused, it was formed six lines of command
> "show, edit, and destroy", an amount equal to the number of records in
> the table "member". but does not display the contents of the table
> "member" it.
>

try looking for set_table_name syntax to set the table name that you want
to use


>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Filter on multiple select

2012-12-13 Thread Jim Ruther Nill
On Thu, Dec 13, 2012 at 10:23 PM, Lorenz Blackbird wrote:

> Hello,
>
> I have a many-to-many relationship between the model "exams" and the
> model "students", in the middle I have the model "registrations".
>
> Students are registered to a "course" (another model) and any exam is
> associated to a "course".
>
> I create a view in exams that permit to add the students with multiple
> selection:
>
> <%= f.select :student_ids, Student.all.map { |student| [student.name,
> student.id] }, { }, { multiple: true }
>
> but this solution show me all students in the db. I wish I had only the
> students registered in the same course of exam.
>
> I don't know how filter the array and put it in the multiple selection.
>

I think you need to add a relationship between a course and a user and use
that relationship to figure out that list of student choices eligible for
the exam.


>
> Any suggestion?
>
> Thanks to all.
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: make rails connect with database

2012-12-13 Thread Jim Ruther Nill
On Thu, Dec 13, 2012 at 5:38 PM, Mas Bejo  wrote:

> i can't understand this command
> "rails g scaffold  --migration false"
>
> can you describe it more?
>

if you have a table called comments in your current database, and you want
to generate
the model, controller and views for that table, you need to run

rails g scaffold comment

but that will generate a migration file for creating the table on the db.
 since you
already have the tables, you can pass --migration false to skip creating
the migration.


>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] change development database

2012-12-13 Thread Jim Ruther Nill
On Thu, Dec 13, 2012 at 12:01 AM, Nehemiah Dacres wrote:

> I accidentally chose the wrong database name for an existing i want to use
> in development. I changed the name in database.yaml  but I still get the
> same error
> "Mysql2::Error: PROCEDURE test.NADAnnotation_All_S does not exist: call
> NADAnnotation_All_S()" which is the name of a stored routine in a different
> database. I ran rake db:migrate, what else do I have to do?
>

did you restart your server after you changed database.yml?

>  --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/jmBDIay2ZBIJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Thin server giving Stack level too deep error

2012-12-12 Thread Jim Ruther Nill
On Thu, Dec 13, 2012 at 1:56 PM, sumit srivastava <
sumit.theinvinci...@gmail.com> wrote:

> On 13 December 2012 11:23, Jim Ruther Nill  wrote:
>
>>
>>
>>
>> On Thu, Dec 13, 2012 at 1:48 PM, sumit srivastava <
>> sumit.theinvinci...@gmail.com> wrote:
>>
>>>
>>> On 13 December 2012 11:17, sumit srivastava <
>>> sumit.theinvinci...@gmail.com> wrote:
>>>
>>>>
>>>> On 13 December 2012 11:13, Jim Ruther Nill  wrote:
>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Thu, Dec 13, 2012 at 1:31 PM, Sumit Srivastava <
>>>>> sumit.theinvinci...@gmail.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I am using thin web server in my rails project. But it gives stack
>>>>>> level too deep error. Couldn't find any appropriate solution to this.
>>>>>> I have tried updating the ruby but didn't help.
>>>>>>
>>>>>
>>>>> can you post the entire trace here?  just a quick check would be to
>>>>> create a new rails app
>>>>> using the same version of thin that you're getting issues with.  If it
>>>>> works, then there's
>>>>> something wrong with your config.  First thing to look at would be the
>>>>> initializers you added.
>>>>> Next would be to look at your environment config.
>>>>>
>>>>
>>>> This is what I get in trace,
>>>>
>>>> HTTP/1.1 500 Internal Server Error
>>>> Connection: close
>>>> Server: thin 1.3.1 codename Triple Espresso
>>>>
>>>> SystemStackError: stack level too deep
>>>>
>>>
>>> The same thing works on some systems while fails on some. Googled about
>>> it and found several people have been facing this issue with thin. Didn't
>>> get any concrete solution.
>>>
>>
>> have you tried reinstalling the gem? or using a lower version of the gem?
>>
>
> Yes, I have also mentioned that it works on some systems but creates
> problem on few.
>

Yep, I read that part.  Sorry, I don't have any ideas anymore. Good luck.


>
>>
>>>
>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> Regards,
>>>>>> Sumit
>>>>>>
>>>>>> --
>>>>>> 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+unsubscr...@googlegroups.com.
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msg/rubyonrails-talk/-/5IEH7kxOki8J.
>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> -
>>>>> visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>  --
>>> 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+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>>
>> --
>> -
>> visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Thin server giving Stack level too deep error

2012-12-12 Thread Jim Ruther Nill
On Thu, Dec 13, 2012 at 1:48 PM, sumit srivastava <
sumit.theinvinci...@gmail.com> wrote:

>
> On 13 December 2012 11:17, sumit srivastava  > wrote:
>
>>
>> On 13 December 2012 11:13, Jim Ruther Nill  wrote:
>>
>>>
>>>
>>>
>>> On Thu, Dec 13, 2012 at 1:31 PM, Sumit Srivastava <
>>> sumit.theinvinci...@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I am using thin web server in my rails project. But it gives stack
>>>> level too deep error. Couldn't find any appropriate solution to this.
>>>> I have tried updating the ruby but didn't help.
>>>>
>>>
>>> can you post the entire trace here?  just a quick check would be to
>>> create a new rails app
>>> using the same version of thin that you're getting issues with.  If it
>>> works, then there's
>>> something wrong with your config.  First thing to look at would be the
>>> initializers you added.
>>> Next would be to look at your environment config.
>>>
>>
>> This is what I get in trace,
>>
>> HTTP/1.1 500 Internal Server Error
>> Connection: close
>> Server: thin 1.3.1 codename Triple Espresso
>>
>> SystemStackError: stack level too deep
>>
>
> The same thing works on some systems while fails on some. Googled about it
> and found several people have been facing this issue with thin. Didn't get
> any concrete solution.
>

have you tried reinstalling the gem? or using a lower version of the gem?


>
>>
>>>
>>>
>>>>
>>>> Regards,
>>>> Sumit
>>>>
>>>> --
>>>> 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+unsubscr...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msg/rubyonrails-talk/-/5IEH7kxOki8J.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> -
>>> visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>  --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Thin server giving Stack level too deep error

2012-12-12 Thread Jim Ruther Nill
On Thu, Dec 13, 2012 at 1:31 PM, Sumit Srivastava <
sumit.theinvinci...@gmail.com> wrote:

> Hi,
>
> I am using thin web server in my rails project. But it gives stack level
> too deep error. Couldn't find any appropriate solution to this.
> I have tried updating the ruby but didn't help.
>

can you post the entire trace here?  just a quick check would be to create
a new rails app
using the same version of thin that you're getting issues with.  If it
works, then there's
something wrong with your config.  First thing to look at would be the
initializers you added.
Next would be to look at your environment config.


>
> Regards,
> Sumit
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/5IEH7kxOki8J.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: make rails connect with database

2012-12-12 Thread Jim Ruther Nill
On Thu, Dec 13, 2012 at 11:22 AM, Mas Bejo  wrote:

> i try open schema.rb, and i saw this code
> 
> ActiveRecord::Schema.define(:version => 20121201063411) do
>
>   create_table "anggota", :force => true do |t|
> t.string   "nama"
> t.text "alamat"
> t.text "no_telp"
> t.datetime "waktu_daftar"
> t.datetime "created_at",   :null => false
> t.datetime "updated_at",   :null => false
>   end
>
>   create_table "bukus", :force => true do |t|
> t.string   "isbn"
> t.string   "judul"
> t.string   "penulis"
> t.string   "penerbit"
> t.string   "kategori"
> t.integer  "edisi"
> t.integer  "jumlah"
> t.integer  "jumlah_dipinjam"
> t.datetime "created_at",  :null => false
> t.datetime "updated_at",  :null => false
>   end
>
>   create_table "posts", :force => true do |t|
> t.string   "name"
> t.string   "title"
> t.text "content"
> t.datetime "created_at", :null => false
> t.datetime "updated_at", :null => false
>   end
>
> end
> --
>
> it say create_table "name of table", but the problem is i have been have
> that table in my database, and i didn't want to change that table.
>

first run rake db:schema:dump to generate your schema from the current
database.
Then if you want to run a scaffold (I've just tested this one, I don't
actually use
scaffold), use

rails g scaffold  --migration false


>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] make rails connect with database

2012-12-12 Thread Jim Ruther Nill
On Thu, Dec 13, 2012 at 10:54 AM, Mas Bejo  wrote:

> i'm newbie in rails. i have problem with how to connect rails with
> database. before i can connect it with command
> "rake db:create" to create database.
> and "rake db:migrate" to migrate schema to database.


> but, i want to connect rails with database that i have before, not
> create it via rails. can you help me?
>

just setup your config/database.yml and that should work.  however, when
you want to collaborate with someone, you have to depend on schema.rb
rather than migrations to create the database.


>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Nested Form with Add/Remove Attributes Button.

2012-12-12 Thread Jim Ruther Nill
On Thu, Dec 13, 2012 at 6:18 AM, fuzzy  wrote:

> Hi,
>
> I finally, w/paid help, got my nested form working such that the add/
> remove attributes button works.
>
>
> Now I am wondering if it is possible to only have the 'remove'
> attributes button, only show up after the first row of attributes.
>
> For example ... my form starts out with its initial row of attributes,
> and presently the 'remove' button is at the end of this row, I would
> prefer that there be no button.  Now lets assume I want to add another
> row of attributes and so I click on the 'add attributes' button and
> another row of attributes are added with the 'remove' button at the
> end of this row. I would like the 'remove' button to only show up with
> this second row and any subsequent rows of attributes.
>
> I was reading a blog on the 'link_to_if', options at this site:
>
> http://groups.google.com/group/rubyonrails-talk/post?hl=en
>
> and I was wondering where I would use this option and how.
>
> My thinking is that I would like to count how many times the 'add
> attribute' button is activated and then store this in a global
> variable that is availabe to the 'remove' attributes button such that
> is only appears is the count is > 1.
>
> So maybe I could write a method that counts the number of times the
> 'add attribute' button is activated in the helper where the 'add
> attribute' button is defined?
>
> Any thoughts, suggestions or hopefully encouragement as to how to
> solve this issue?
>

I think the best solution for this issue is using css.  Look at
http://www.w3schools.com/cssref/sel_firstchild.asp.
You can also create a js solution where you always remove the delete button
whenever you add/remove a row.


>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Adding a hyperlink to a pop-up window on a form field label in Rails

2012-12-11 Thread Jim Ruther Nill
On Wed, Dec 12, 2012 at 10:47 AM, Walter Lee Davis wrote:

>
> On Dec 11, 2012, at 7:12 PM, scottc wrote:
>
> > Is there a way to embed a hyperlink in a form label in Rails using
> link_to?
> >
> > I am trying to do this in a form field as follows:
> >
> > <%= f.label "Accept Terms of Service?" %>
>
> Try this:
>
> <%= f.label("#{link_to('Accept Terms of Service',
> '/terms_of_service.html')}".html_safe) %>
>

Looking at the api, I think it's possible to pass a block for a nested
label tag

http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-label


>
> Walter
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: Values not being being reflected on page after validation error but model has the values

2012-12-10 Thread Jim Ruther Nill
On Mon, Dec 10, 2012 at 3:45 PM, Jim Ruther Nill  wrote:

>
>
>
> On Mon, Dec 10, 2012 at 3:42 PM, rubyrookie  wrote:
>
>> Thank you very much. I will read up on the difference. Sorry should have
>> bolded my answers.
>
>
> No worries.  If you're looking for the difference, @payment (as you
> already know) uses the same
> record as the one you have in your controllers.  If you use
> @merchant.payments.build, you're
> creating a new payment record which does not contain the values submitted
> by the user :)
>

regarding your question on the field_error_proc. read this one and please
don't email users directly :)

http://guides.rubyonrails.org/configuring.html#configuring-action-view


>
>
>>
>>
>> On Sunday, December 9, 2012 11:33:56 PM UTC-8, jim wrote:
>>
>>>
>>>
>>>
>>> On Mon, Dec 10, 2012 at 3:16 PM, rubyrookie  wrote:
>>>
>>>>
>>>>
>>>> On Sunday, December 9, 2012 11:08:57 PM UTC-8, jim wrote:
>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Mon, Dec 10, 2012 at 2:26 PM, rubyrookie  wrote:
>>>>>
>>>>>> No error . Validation error is populated but form does not retain
>>>>>> values. Payment object has the values though.
>>>>>>
>>>>>
>>>>> This is still confusing.  What exactly do you want to do?
>>>>>
>>>>>- Show the validation errors on the form page? -> Yes, it is being
>>>>>displayed
>>>>>- Fix the payment process because you don't know what validations
>>>>>are failing? No, I know the validations are failing
>>>>> - retain the values passed by the user when validations fail?
>>>>>Yes. The form is not displayed the retained values. I want this to be
>>>>>fixed.
>>>>>
>>>>>
>>> It would've helped if you somehow bolded your answers. anyway, you
>>> should be able to do that by
>>> changing this line
>>>
>>> <%= form_for([@merchant, @merchant.payments.build]) do |f| %>
>>>
>>> to
>>>
>>> <%= form_for([@merchant, @payment]) do |f| %>
>>>
>>> Good luck!
>>>
>>>
>>>>
>>>>>
>>>>>>
>>>>>> On Sunday, December 9, 2012 9:53:37 PM UTC-8, rubyrookie wrote:
>>>>>>
>>>>>>> I have a relationship where a merchant can have multiple payments. I
>>>>>>> am posting payments to a merchant and there is a validation error. 
>>>>>>> Payment
>>>>>>> object does have the values retained. Can some one help me fix the 
>>>>>>> issue?
>>>>>>>
>>>>>>> View Code->
>>>>>>>
>>>>>>> <%= @merchant.name %>
>>>>>>>
>>>>>>> <%= form_for([@merchant, @merchant.payments.build]) do |f| %>
>>>>>>>
>>>>>>> <% if @payment.errors.any? %>
>>>>>>> 
>>>>>>> <%= pluralize(@payment.errors.**count, "error") %>
>>>>>>> prohibited this payment from being saved:
>>>>>>>
>>>>>>> 
>>>>>>> <% @payment.errors.full_messages.**each do |msg| %>
>>>>>>> 
>>>>>>>  <%= msg %>
>>>>>>> 
>>>>>>> <% end %>
>>>>>>> 
>>>>>>> 
>>>>>>> <% end %>
>>>>>>>
>>>>>>> test
>>>>>>> // Prints the values correctly
>>>>>>> <%= @payment.credit_card_number %>
>>>>>>> <%= @payment.zip %>
>>>>>>> <%= @payment.country %>
>>>>>>>
>>>>>>> 
>>>>>>> <%= f.label :credit_card_number   %>
>>>>>>> 
>>>>>>>  <%= f.text_field :credit_card_number , :autocomplete => "off" %>
>>>>>>> 
>>>>>>> 
>>>>>>> <%= f.label :address_line_2 %>
>>>>>>>  
>>>>>>> <%= f.text_field :address_line_2 %>
>>>>>>> 
>>>>>>> 
>>>>>>>  <%= f

Re: [Rails] Re: Values not being being reflected on page after validation error but model has the values

2012-12-09 Thread Jim Ruther Nill
On Mon, Dec 10, 2012 at 3:42 PM, rubyrookie  wrote:

> Thank you very much. I will read up on the difference. Sorry should have
> bolded my answers.


No worries.  If you're looking for the difference, @payment (as you already
know) uses the same
record as the one you have in your controllers.  If you use
@merchant.payments.build, you're
creating a new payment record which does not contain the values submitted
by the user :)


>
>
> On Sunday, December 9, 2012 11:33:56 PM UTC-8, jim wrote:
>
>>
>>
>>
>> On Mon, Dec 10, 2012 at 3:16 PM, rubyrookie  wrote:
>>
>>>
>>>
>>> On Sunday, December 9, 2012 11:08:57 PM UTC-8, jim wrote:
>>>



 On Mon, Dec 10, 2012 at 2:26 PM, rubyrookie  wrote:

> No error . Validation error is populated but form does not retain
> values. Payment object has the values though.
>

 This is still confusing.  What exactly do you want to do?

- Show the validation errors on the form page? -> Yes, it is being
displayed
- Fix the payment process because you don't know what validations
are failing? No, I know the validations are failing
 - retain the values passed by the user when validations fail? Yes.
The form is not displayed the retained values. I want this to be fixed.


>> It would've helped if you somehow bolded your answers. anyway, you should
>> be able to do that by
>> changing this line
>>
>> <%= form_for([@merchant, @merchant.payments.build]) do |f| %>
>>
>> to
>>
>> <%= form_for([@merchant, @payment]) do |f| %>
>>
>> Good luck!
>>
>>
>>>

>
> On Sunday, December 9, 2012 9:53:37 PM UTC-8, rubyrookie wrote:
>
>> I have a relationship where a merchant can have multiple payments. I
>> am posting payments to a merchant and there is a validation error. 
>> Payment
>> object does have the values retained. Can some one help me fix the issue?
>>
>> View Code->
>>
>> <%= @merchant.name %>
>>
>> <%= form_for([@merchant, @merchant.payments.build]) do |f| %>
>>
>> <% if @payment.errors.any? %>
>> 
>> <%= pluralize(@payment.errors.**count, "error") %>
>> prohibited this payment from being saved:
>>
>> 
>> <% @payment.errors.full_messages.**each do |msg| %>
>> 
>>  <%= msg %>
>> 
>> <% end %>
>> 
>> 
>> <% end %>
>>
>> test
>> // Prints the values correctly
>> <%= @payment.credit_card_number %>
>> <%= @payment.zip %>
>> <%= @payment.country %>
>>
>> 
>> <%= f.label :credit_card_number   %>
>> 
>>  <%= f.text_field :credit_card_number , :autocomplete => "off" %>
>> 
>> 
>> <%= f.label :address_line_2 %>
>>  
>> <%= f.text_field :address_line_2 %>
>> 
>> 
>>  <%= f.label :city %>
>> 
>> <%= f.text_field :city %>
>> 
>> 
>> <%= f.label :zip %>
>> 
>> <%= f.text_field :zip %>
>> 
>> 
>> <%= f.label :country %>
>> 
>>  <%= f.text_field :country %>
>> 
>>
>> 
>> <%= f.submit %>
>> 
>> <% end %>
>>
>> Controller code->
>>
>> class PaymentsController < ApplicationController
>>   # GET /merchants/1
>>   # GET /merchants/1.json
>>   def new
>> @payment = Payment.new
>> @merchant = Merchant.find(params[:**merchant_id])
>> respond_to do |format|
>>   format.html # show.html.erb
>> end
>>   end
>>
>>   def index
>>
>> if params[:merchant_id]
>>   @payments =  Merchant.find(params[:**merchant_id]).payments
>> else
>>   @payments = Payment.all
>> end
>>
>> respond_to do |format|
>>   format.html # index.html.erb
>>   format.json { render json: @merchants }
>> end
>>   end
>>
>>def create
>> @merchant = Merchant.find(params[:**merchant_id])
>> @payment = @merchant.payments.create(**params[:payment])
>>
>> respond_to do |format|
>>   if @merchant.save
>> format.html {redirect_to merchants_path}
>>   else
>> format.html { render action: "new" }
>>
>>   end
>> end
>>
>>   end
>>
>> end
>>
>>  --
> You received this message because you are subscribed to the Google
> Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonra...@googlegroups.**com.
> To unsubscribe from this group, send email to rubyonrails-ta...@**
> googlegroups**.com.
> To view this discussion on the web visit https://groups.google.com/d/*
> *ms**g/rubyonrails-talk/-/**jSZvC8ID4**ycJ
> .
>
> For more options, visit 
> https://groups.google.com/**grou**ps/opt_out
> .
>
>
>



 -

Re: [Rails] Conditional background color of rows

2012-12-09 Thread Jim Ruther Nill
On Mon, Dec 10, 2012 at 3:34 PM, Sumit Srivastava <
sumit.theinvinci...@gmail.com> wrote:

> Hi,
>
> I am using dataTables to render my content onto a view. I need to change
> the background color of a row depending upon ratio of values of two
> columns. How shall I proceed. I went through following page on dataTables
> website but it didn't work for me.
>
>http://www.datatables.net/examples/advanced_init/row_callback.html


I haven't used datatables before but I personally think that this question
is not in any way
related to rails.  So you'd get better answers there.  But if someone has
already used it and
is willing to answer, then lucky you.


>
>
> Regards,
> Sumit
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/SphOItz_338J.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: Values not being being reflected on page after validation error but model has the values

2012-12-09 Thread Jim Ruther Nill
On Mon, Dec 10, 2012 at 3:16 PM, rubyrookie  wrote:

>
>
> On Sunday, December 9, 2012 11:08:57 PM UTC-8, jim wrote:
>
>>
>>
>>
>> On Mon, Dec 10, 2012 at 2:26 PM, rubyrookie  wrote:
>>
>>> No error . Validation error is populated but form does not retain
>>> values. Payment object has the values though.
>>>
>>
>> This is still confusing.  What exactly do you want to do?
>>
>>- Show the validation errors on the form page? -> Yes, it is being
>>displayed
>>- Fix the payment process because you don't know what validations are
>>failing? No, I know the validations are failing
>>- retain the values passed by the user when validations fail? Yes.
>>The form is not displayed the retained values. I want this to be fixed.
>>
>>
It would've helped if you somehow bolded your answers. anyway, you should
be able to do that by
changing this line

<%= form_for([@merchant, @merchant.payments.build]) do |f| %>

to

<%= form_for([@merchant, @payment]) do |f| %>

Good luck!


>
>>
>>>
>>> On Sunday, December 9, 2012 9:53:37 PM UTC-8, rubyrookie wrote:
>>>
 I have a relationship where a merchant can have multiple payments. I am
 posting payments to a merchant and there is a validation error. Payment
 object does have the values retained. Can some one help me fix the issue?

 View Code->

 <%= @merchant.name %>

 <%= form_for([@merchant, @merchant.payments.build]) do |f| %>

 <% if @payment.errors.any? %>
 
 <%= pluralize(@payment.errors.**coun**t, "error") %> prohibited
 this payment from being saved:

 
 <% @payment.errors.full_messages.each do |msg| %>
 
  <%= msg %>
 
 <% end %>
 
 
 <% end %>

 test
 // Prints the values correctly
 <%= @payment.credit_card_number %>
 <%= @payment.zip %>
 <%= @payment.country %>

 
 <%= f.label :credit_card_number   %>
 
  <%= f.text_field :credit_card_number , :autocomplete => "off" %>
 
 
 <%= f.label :address_line_2 %>
  
 <%= f.text_field :address_line_2 %>
 
 
  <%= f.label :city %>
 
 <%= f.text_field :city %>
 
 
 <%= f.label :zip %>
 
 <%= f.text_field :zip %>
 
 
 <%= f.label :country %>
 
  <%= f.text_field :country %>
 

 
 <%= f.submit %>
 
 <% end %>

 Controller code->

 class PaymentsController < ApplicationController
   # GET /merchants/1
   # GET /merchants/1.json
   def new
 @payment = Payment.new
 @merchant = Merchant.find(params[:**merchant**_id])
 respond_to do |format|
   format.html # show.html.erb
 end
   end

   def index

 if params[:merchant_id]
   @payments =  Merchant.find(params[:**merchan**t_id]).payments
 else
   @payments = Payment.all
 end

 respond_to do |format|
   format.html # index.html.erb
   format.json { render json: @merchants }
 end
   end

   def create
 @merchant = Merchant.find(params[:**merchant**_id])
 @payment = @merchant.payments.create(**para**ms[:payment])

 respond_to do |format|
   if @merchant.save
 format.html {redirect_to merchants_path}
   else
 format.html { render action: "new" }

   end
 end

   end

 end

  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ruby on Rails: Talk" group.
>>> To post to this group, send email to rubyonra...@googlegroups.**com.
>>> To unsubscribe from this group, send email to rubyonrails-ta...@**
>>> googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> msg/rubyonrails-talk/-/**jSZvC8ID4ycJ
>>> .
>>>
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>> --**--**-
>> visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/DbPFCiH_y0UJ.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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.

Re: [Rails] Re: Values not being being reflected on page after validation error but model has the values

2012-12-09 Thread Jim Ruther Nill
On Mon, Dec 10, 2012 at 2:26 PM, rubyrookie  wrote:

> No error . Validation error is populated but form does not retain values.
> Payment object has the values though.
>

This is still confusing.  What exactly do you want to do?

   - Show the validation errors on the form page?
   - Fix the payment process because you don't know what validations are
   failing?
   - retain the values passed by the user when validations fail?



>
> On Sunday, December 9, 2012 9:53:37 PM UTC-8, rubyrookie wrote:
>
>> I have a relationship where a merchant can have multiple payments. I am
>> posting payments to a merchant and there is a validation error. Payment
>> object does have the values retained. Can some one help me fix the issue?
>>
>> View Code->
>>
>> <%= @merchant.name %>
>>
>> <%= form_for([@merchant, @merchant.payments.build]) do |f| %>
>>
>> <% if @payment.errors.any? %>
>> 
>> <%= pluralize(@payment.errors.**count, "error") %> prohibited this
>> payment from being saved:
>>
>> 
>> <% @payment.errors.full_messages.**each do |msg| %>
>> 
>> <%= msg %>
>> 
>> <% end %>
>> 
>> 
>> <% end %>
>>
>> test
>> // Prints the values correctly
>> <%= @payment.credit_card_number %>
>> <%= @payment.zip %>
>> <%= @payment.country %>
>>
>> 
>> <%= f.label :credit_card_number   %>
>> 
>> <%= f.text_field :credit_card_number , :autocomplete => "off" %>
>> 
>> 
>> <%= f.label :address_line_2 %>
>> 
>> <%= f.text_field :address_line_2 %>
>> 
>> 
>> <%= f.label :city %>
>> 
>> <%= f.text_field :city %>
>> 
>> 
>> <%= f.label :zip %>
>> 
>> <%= f.text_field :zip %>
>> 
>> 
>> <%= f.label :country %>
>> 
>> <%= f.text_field :country %>
>> 
>>
>> 
>> <%= f.submit %>
>> 
>> <% end %>
>>
>> Controller code->
>>
>> class PaymentsController < ApplicationController
>>   # GET /merchants/1
>>   # GET /merchants/1.json
>>   def new
>> @payment = Payment.new
>> @merchant = Merchant.find(params[:**merchant_id])
>> respond_to do |format|
>>   format.html # show.html.erb
>> end
>>   end
>>
>>   def index
>>
>> if params[:merchant_id]
>>   @payments =  Merchant.find(params[:**merchant_id]).payments
>> else
>>   @payments = Payment.all
>> end
>>
>> respond_to do |format|
>>   format.html # index.html.erb
>>   format.json { render json: @merchants }
>> end
>>   end
>>
>>   def create
>> @merchant = Merchant.find(params[:**merchant_id])
>> @payment = @merchant.payments.create(**params[:payment])
>>
>> respond_to do |format|
>>   if @merchant.save
>> format.html {redirect_to merchants_path}
>>   else
>> format.html { render action: "new" }
>>
>>   end
>> end
>>
>>   end
>>
>> end
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/jSZvC8ID4ycJ.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Values not being being reflected on page after validation error but model has the values

2012-12-09 Thread Jim Ruther Nill
On Mon, Dec 10, 2012 at 1:53 PM, rubyrookie  wrote:

> I have a relationship where a merchant can have multiple payments. I am
> posting payments to a merchant and there is a validation error. Payment
> object does have the values retained. Can some one help me fix the issue?
>
> View Code->
>
> <%= @merchant.name %>
>
> <%= form_for([@merchant, @merchant.payments.build]) do |f| %>
>
> <% if @payment.errors.any? %>
> 
> <%= pluralize(@payment.errors.count, "error") %> prohibited this
> payment from being saved:
>
> 
> <% @payment.errors.full_messages.each do |msg| %>
> 
> <%= msg %>
> 
> <% end %>
> 
> 
> <% end %>
>
> test
> // Prints the values correctly
> <%= @payment.credit_card_number %>
> <%= @payment.zip %>
> <%= @payment.country %>
>
> 
> <%= f.label :credit_card_number   %>
> 
> <%= f.text_field :credit_card_number , :autocomplete => "off" %>
> 
> 
> <%= f.label :address_line_2 %>
> 
> <%= f.text_field :address_line_2 %>
> 
> 
> <%= f.label :city %>
> 
> <%= f.text_field :city %>
> 
> 
> <%= f.label :zip %>
> 
> <%= f.text_field :zip %>
> 
> 
> <%= f.label :country %>
> 
> <%= f.text_field :country %>
> 
>
> 
> <%= f.submit %>
> 
> <% end %>
>
> Controller code->
>
> class PaymentsController < ApplicationController
>   # GET /merchants/1
>   # GET /merchants/1.json
>   def new
> @payment = Payment.new
> @merchant = Merchant.find(params[:merchant_id])
> respond_to do |format|
>   format.html # show.html.erb
> end
>   end
>
>   def index
>
> if params[:merchant_id]
>   @payments =  Merchant.find(params[:merchant_id]).payments
> else
>   @payments = Payment.all
> end
>
> respond_to do |format|
>   format.html # index.html.erb
>   format.json { render json: @merchants }
> end
>   end
>
>   def create
> @merchant = Merchant.find(params[:merchant_id])
> @payment = @merchant.payments.create(params[:payment])
>
> respond_to do |format|
>   if @merchant.save
> format.html {redirect_to merchants_path}
>   else
> format.html { render action: "new" }
>
>   end
> end
>
>   end
>
> end
>

what error do you get?


>
>  --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/PTxFOGJob9sJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] link_to popup

2012-12-09 Thread Jim Ruther Nill
On Mon, Dec 10, 2012 at 12:55 PM, avinash behera
wrote:

> Should we use javascript ot jquery to achieve this?


I remember in rails 2 that link_to has a popup option which opens a new
window.  Looking at
the api right now, the option was removed.  so I guess you may need to
implement your
own js solution

http://apidock.com/rails/v2.3.8/ActionView/Helpers/UrlHelper/link_to


>
>
> On Mon, Dec 10, 2012 at 10:23 AM, Walter Lee Davis wrote:
>
>> That's an implementation detail of your browser. The target="_blank" bit
>> is baked into every browser back to Netscape 2. How that browser chooses to
>> implement the window (or tab) is its concern, not something you can change
>
>
>
>  --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Joining two tables giving ambigous column error on mysql

2012-12-06 Thread Jim Ruther Nill
On Fri, Dec 7, 2012 at 3:17 PM, sumit srivastava <
sumit.theinvinci...@gmail.com> wrote:

> On 7 December 2012 10:05, Jim Ruther Nill  wrote:
>
>>
>>
>>
>> On Fri, Dec 7, 2012 at 12:20 PM, Sumit Srivastava <
>> sumit.theinvinci...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I am doing a join of two tables with a column with same name in both. I
>>> am using "includes" to have a full join. This is giving ambiguous column
>>> error. The columns cannot be removed from either of those and renaming any
>>> of the two would involve two many changes. So, is there any way this can be
>>> resolved?
>>>
>>
>> try this
>>
>> Foo.includes(:bar).order('foos.name, bars.name').where('foos.name = ?
>> AND bars.name = ?', 'fooname', 'barname')
>>
>> just specify the table you are trying to access.
>>
>
> How to write test cases for such errors? Is it possible?
>

If you're going to ask me, I personally think that this specific error
should not be written a test case.
In the first place, the code will not run if there is such an error so that
code shouldn't be committed.


>
>
>
>>
>>
>>>
>>> Regards,
>>> Sumit
>>>
>>> --
>>> 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+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/rubyonrails-talk/-/jq7KYxfa_9cJ.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>>
>> --
>> -
>> visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Joining two tables giving ambigous column error on mysql

2012-12-06 Thread Jim Ruther Nill
On Fri, Dec 7, 2012 at 12:20 PM, Sumit Srivastava <
sumit.theinvinci...@gmail.com> wrote:

> Hi,
>
> I am doing a join of two tables with a column with same name in both. I am
> using "includes" to have a full join. This is giving ambiguous column
> error. The columns cannot be removed from either of those and renaming any
> of the two would involve two many changes. So, is there any way this can be
> resolved?
>

try this

Foo.includes(:bar).order('foos.name, bars.name').where('foos.name = ? AND
bars.name = ?', 'fooname', 'barname')

just specify the table you are trying to access.


>
> Regards,
> Sumit
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/jq7KYxfa_9cJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] copy common attributes

2012-12-06 Thread Jim Ruther Nill
On Fri, Dec 7, 2012 at 9:30 AM, renu mehta  wrote:

> Hello,
>
> If I have a model A as :
>
> name
> address
> phone
>
> and model B as:
>
> name
> address
> email
>
> Is it possible to copy a record from A to B with one statement? I am
> trying :
>
> @a=A.find(2)
> a_attributes=@a.attributes
> a_attributes.delete "id"
> @b=B.create(a_attributes)
>
> @b.save!
>
> And I am getting an exception :
>
> unknown attribute: phone
>
> How can do this without going through each attribute individually?
>

use slice.

B.create a.attributes.slice(:name, :address, :email)


>
> Thanks.
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] access json data from rails controller in ajax call and process it

2012-12-05 Thread Jim Ruther Nill
On Wed, Dec 5, 2012 at 7:02 PM, ruby rails  wrote:

> I am building a Task Management System and have implemented
> fullcalendar.js in it. I need to get the pending tasks and change the
> color of those pending tasks. I am getting the instance variable of
> pending tasks details in the rails controller. But in the ajax request I
> am not able to loop it.
>
> Please find my code below.
>
>   $('.task_name').live('click', function () {
> alert(this.id);
> $.ajax({
> url: 'pending_task_details',
> data: {
> task_id: this.id
> },
> success: function (data, response, event, date) { <%
> for date_cell in
> @pending_tasks.start_date..@pending_tasks.end_date %>
> getCellFromDate(date_cell, calInstance); <% end %>
> }
> });
> });
>

you simply can't do this. try

$.ajax({
  url: 'pending_task_details',
  data: { task_id: this.id },
  dataType: 'json',
  success: function(data) {
// do something USING javascript with data here. don't use ruby
data.map(function(d) {
  return d.dates.each(function(date) { return
getCellFromDate(data[0].date, calInstance) });
});
  }
})

something like this. i'm pretty sure this still has some errors but you
should be able to work with that.
just remember to add a dates key with the range of date when you render
json.


>
> The above is the logic I need to implement. But I am not getting
> @pending_tasks.start_date in the view.
>
> In the console I am getting the tasks details
> # user_id: 2, description: \"Description4\", pm_id: nil, created_at:
> \"2012-11-01 09:42:37\", updated_at: \"2012-11-01 09:42:37\",
> percent_completed: \"12\", status: \"completed\", due_date: nil,
> start_date: \"2012-11-01\", end_date: \"2012-11-08\", priority: \"low\",
> days_left: nil>
>
> In the tasks controller I am getting the pending tasks as.
>
>   def pending_task_details
> @pending_tasks = Task.find_by_id(params[:task_id])
> p "The pending tasks are..",@pending_tasks.inspect
>
> #(Date.parse(@pending_tasks.start_date.to_s)..Date.parse(@pending_tasks.end_date.to_s)).each
> { |date| render :json=>[date.strftime('%a %d %b %Y')] and return}
> render :json=>@pending_tasks
>   end
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Abridged summary of rubyonrails-talk@googlegroups.com - 37 Messages in 16 Topics

2012-12-04 Thread Jim Ruther Nill
On Wed, Dec 5, 2012 at 8:20 AM, Jordon Bedwell  wrote:

> On Tue, Dec 4, 2012 at 5:09 PM, Arpit Prasad 
> wrote:
> > We are seeking a front-end Rails developer who has experience developing
> > consumer facing web sites.
>
> You should also probably hire an IT team that can teach you how to
> create topics on mailing lists, mostly (and hopefully) without
> including almost every topic created this week on the Rails list.
>

>From the looks of it, I think he tried to reply to a daily digest email
instead
of creating a new thread.


>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] create conditions in model

2012-12-03 Thread Jim Ruther Nill
On Tue, Dec 4, 2012 at 11:46 AM, Jim Ruther Nill  wrote:

>
>
>
> On Mon, Dec 3, 2012 at 6:26 AM, Jean  wrote:
>
>> Hello guys,
>>
>> I trying to create the conditions of my search, but I have some troubles.
>>
>> This is the method I'm trying to create in my model.
>>
>> def self.searchadv(title, place, category, date)
>> !title.blank? ? conditions = ['title LIKE ?', "%#{title}%"] : conditions 
>> = []
>> if conditions
>> !place.blank? ? conditions << [' AND place LIKE ?', "%#{place}%"] :  
>> conditions << []
>> !place.blank? ? conditions << [' AND category LIKE ?', "%#{place}%"] 
>> :  conditions << []
>> !place.blank? ? conditions << [' AND date LIKE ?', "%#{place}%"] :  
>> conditions << []
>> else
>> !place.blank? ? conditions << [' place LIKE ?', "%#{place}%"] :  
>> conditions << []
>> !place.blank? ? conditions << [' category LIKE ?', "%#{place}%"] :  
>> conditions << []
>> !place.blank? ? conditions << [' date LIKE ?', "%#{place}%"] :  
>> conditions << []
>> end
>> find(:all, :conditions => conditions)end
>>
>> I get this error
>>
>> wrong number of bind variables (4 for 1) in: title LIKE ?
>>
>> if I delete this:
>>
>> if conditions
>> !place.blank? ? conditions << [' AND place LIKE ?', "%#{place}%"] :  
>> conditions << []
>> !place.blank? ? conditions << [' AND category LIKE ?', "%#{place}%"] :  
>> conditions << []
>> !place.blank? ? conditions << [' AND date LIKE ?', "%#{place}%"] :  
>> conditions << []else
>> !place.blank? ? conditions << [' place LIKE ?', "%#{place}%"] :  
>> conditions << []
>> !place.blank? ? conditions << [' category LIKE ?', "%#{place}%"] :  
>> conditions << []
>> !place.blank? ? conditions << [' date LIKE ?', "%#{place}%"] :  
>> conditions << []end
>>
>> Everything works great, but I need this other options in order to create
>> my search and I don't undertand why the error is in the "LiKE"
>>
>> Does anyone could help me please?
>>
>> Thanks in advance!
>>
>
> you can also do it like this
>
> def self.searchadv(title, place, category, date)
>
> klass = scoped
>
> klass = klass.where(conditions for title here) if title.present?klass 
> = klass.where(conditions for place here) if place.present?klass = 
> klass.where(conditions for category here) if category.present?klass = 
> klass.where(conditions for date here) if date.present?
>
> scopedend
>
> This is using rails 3.  But you can still use this for rails 2.3 (i'm not
> sure what version they introduced this),
> you just have to change the where calls to scoped
>

the last line that calls scoped should be klass. my bad.


>
>
>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/rubyonrails-talk/-/6upZgpqP5hMJ.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
>
> --
> -
> visit my blog at http://jimlabs.heroku.com
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] create conditions in model

2012-12-03 Thread Jim Ruther Nill
On Mon, Dec 3, 2012 at 6:26 AM, Jean  wrote:

> Hello guys,
>
> I trying to create the conditions of my search, but I have some troubles.
>
> This is the method I'm trying to create in my model.
>
> def self.searchadv(title, place, category, date)
> !title.blank? ? conditions = ['title LIKE ?', "%#{title}%"] : conditions 
> = []
> if conditions
> !place.blank? ? conditions << [' AND place LIKE ?', "%#{place}%"] :  
> conditions << []
> !place.blank? ? conditions << [' AND category LIKE ?', "%#{place}%"] 
> :  conditions << []
> !place.blank? ? conditions << [' AND date LIKE ?', "%#{place}%"] :  
> conditions << []
> else
> !place.blank? ? conditions << [' place LIKE ?', "%#{place}%"] :  
> conditions << []
> !place.blank? ? conditions << [' category LIKE ?', "%#{place}%"] :  
> conditions << []
> !place.blank? ? conditions << [' date LIKE ?', "%#{place}%"] :  
> conditions << []
> end
> find(:all, :conditions => conditions)end
>
> I get this error
>
> wrong number of bind variables (4 for 1) in: title LIKE ?
>
> if I delete this:
>
> if conditions
> !place.blank? ? conditions << [' AND place LIKE ?', "%#{place}%"] :  
> conditions << []
> !place.blank? ? conditions << [' AND category LIKE ?', "%#{place}%"] :  
> conditions << []
> !place.blank? ? conditions << [' AND date LIKE ?', "%#{place}%"] :  
> conditions << []else
> !place.blank? ? conditions << [' place LIKE ?', "%#{place}%"] :  
> conditions << []
> !place.blank? ? conditions << [' category LIKE ?', "%#{place}%"] :  
> conditions << []
> !place.blank? ? conditions << [' date LIKE ?', "%#{place}%"] :  
> conditions << []end
>
> Everything works great, but I need this other options in order to create
> my search and I don't undertand why the error is in the "LiKE"
>
> Does anyone could help me please?
>
> Thanks in advance!
>

you can also do it like this

def self.searchadv(title, place, category, date)
klass = scoped

klass = klass.where(conditions for title here) if title.present?
 klass = klass.where(conditions for place here) if place.present?
klass = klass.where(conditions for category here) if category.present?
   klass = klass.where(conditions for date here) if date.present?

scopedend

This is using rails 3.  But you can still use this for rails 2.3 (i'm not
sure what version they introduced this),
you just have to change the where calls to scoped



> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/6upZgpqP5hMJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Issue with passing parameter to action using link_to

2012-11-30 Thread Jim Ruther Nill
On Fri, Nov 30, 2012 at 4:56 PM, sumit srivastava <
sumit.theinvinci...@gmail.com> wrote:

> On 30 November 2012 14:16, Colin Law  wrote:
>
>> On 30 November 2012 06:50, sumit srivastava
>>  wrote:
>> > Verified it. Don't have puts anywhere else.
>>
>> Jim asked you to post the contents of the log (log/development.log)
>> when you click the link.  Why have you not done that?  Or have I
>> missed that message?
>>
>
> I haven't posted the log yet because the code I posted is an example of
> what I am using. I can't post the code as it is proprietary. And so the log
> contains info that might violate it.
>

Create a new rails app and try to replicate the behavior.  If you can do
that, we
might be able to help.  If not, consult within your company. Good luck!


>
>
>> 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+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>  --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Issue with passing parameter to action using link_to

2012-11-29 Thread Jim Ruther Nill
On Fri, Nov 30, 2012 at 2:50 PM, sumit srivastava <
sumit.theinvinci...@gmail.com> wrote:

> Verified it. Don't have puts anywhere else.
>

ok.  sorry but I ran out of ideas.  without looking at the logs or the
whole code, i won't be able to
help.


>
> Regards
> Sumit Srivastava
>
> The power of imagination makes us infinite...
>
>
> On 30 November 2012 11:39, Jim Ruther Nill  wrote:
>
>>
>>
>>
>> On Fri, Nov 30, 2012 at 1:50 PM, sumit srivastava <
>> sumit.theinvinci...@gmail.com> wrote:
>>
>>> If it were being directed to some other action, then ***
>>> should not have been printed. And when I am trying to access this parameter
>>> from the view "index.html.haml", its value is printed exactly what is being
>>> passed.
>>>
>>
>> You're right but you may have the same kind of puts code in other parts
>> of your file.  We're just making
>> sure that it really is going to the index action.  Try to use debugger
>> instead of puts when you're debugging.
>> There may be times when you're rendering the same template from a
>> different action which is why
>> the value is printed correctly.
>>
>>
>>>
>>> Regards
>>> Sumit Srivastava
>>>
>>> The power of imagination makes us infinite...
>>>
>>>
>>>
>>> On 30 November 2012 11:12, Jim Ruther Nill  wrote:
>>>
>>>>
>>>>
>>>>
>>>> On Fri, Nov 30, 2012 at 1:32 PM, sumit srivastava <
>>>> sumit.theinvinci...@gmail.com> wrote:
>>>>
>>>>> On 30 November 2012 10:55, Jim Ruther Nill  wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, Nov 30, 2012 at 1:16 PM, sumit srivastava <
>>>>>> sumit.theinvinci...@gmail.com> wrote:
>>>>>>
>>>>>>> On 30 November 2012 10:41, Jim Ruther Nill  wrote:
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Fri, Nov 30, 2012 at 12:51 PM, Sumit Srivastava <
>>>>>>>> sumit.theinvinci...@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> I have a controller named Users with index action.
>>>>>>>>>
>>>>>>>>> def index
>>>>>>>>> puts "* #{params[:city]}"
>>>>>>>>> ...
>>>>>>>>> ...
>>>>>>>>> end
>>>>>>>>>
>>>>>>>>> From the view,
>>>>>>>>> link_to(:city, list_users_with_city_path(:city => city.name))
>>>>>>>>>
>>>>>>>>
>>>>>>>> You implied below that list_users_with_city_path is not yet defined
>>>>>>>> at this point so why is it not giving any errors?  where did you
>>>>>>>> get list_user_with_city_path if you haven't defined it in the
>>>>>>>> routed yet?
>>>>>>>>
>>>>>>>
>>>>>>> Wrote this by mistake. I use it this way after defining the path.
>>>>>>> What doesn't works is,
>>>>>>>
>>>>>>> link_to(:city, users(:city => city.name)
>>>>>>> And this is not giving any errors but nothing is received in the
>>>>>>> index action.
>>>>>>>
>>>>>>
>>>>>> use users_path.  I'm not sure why it's not giving any errors.
>>>>>>
>>>>>
>>>>> Ah! Again I typed wrong. Yes, this is what I used, users_path and
>>>>> seems like I also missed the closing bracket for link_to up here.
>>>>> Certainly, it gave errors without "path".
>>>>>
>>>>> So, with the correct syntax, link_to(:city, users_path(:city =>
>>>>> city.name)), it didn't work.
>>>>>
>>>>
>>>> i'm not sure why params[:city] isn't set when you reach that puts
>>>> statement.  It may be caused by
>>>> a number of things.  Can you check if it really goes to the index
>>>> action, you may have declared
>>

Re: [Rails] Why did we include assets folder in Vendor, Public, lib directorys ?

2012-11-29 Thread Jim Ruther Nill
On Fri, Nov 30, 2012 at 2:45 PM, Fahim Patel  wrote:

> Hi
>
>  As per i know assets folder is include in app directory .
> And when we do asset pre compile than assets folder created in public
> folder.
>
> Q  But what is use of assets folder in vendor and lib directory' s ?
>

I think it's mainly for a more organized way of handling assets as stated
in the guide

http://guides.rubyonrails.org/asset_pipeline.html#asset-organization


>
> Thanks
>
> Fahim
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/o3hsmV6ekgMJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
-
visit my blog at http://jimlabs.heroku.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




  1   2   3   4   >