[Rails] Re: An article: interest in rails is waning

2017-07-27 Thread Michael Pavling


On Thu, Jul 27, 2017 at 8:10 PM, DHH  
> wrote:
>
>> That article is a joke. Of course Rails training is not as much in demand 
>> as it was when it was brand new and nobody knew how to work with it. But to 
>> think that the change in that has anything to do with the rise of 
>> J2EE/Spring?! Come on.
>>
>> On Wednesday, July 26, 2017 at 10:54:58 PM UTC-5, vedant agarwala wrote:
>>>
>>> Hello people,
>>>
>>> I was mildly shocked to read this article:
>>>
>>>
>>> https://thenextweb.com/dd/2017/07/26/ruby-rails-major-coding-bootcamp-ditches-due-waning-interest/?amp=1
>>>
>>> Wanted to know what you think. 
>>>
>>> I kind of agree with the front-end becoming more relevant argument, but 
>>> projects being started on spring instead of rails. Is it really true, or 
>>> more importantly, could it be better ?
>>> Rails is already embracing JavaScript and SPAs with webpacker.
>>>
>>> This article wrote that java is challenging for new devs. Seriously? 
>>> Java is easier than Ruby?!
>>>
>>> I am a big fan of rails, and personally hate java. But my opinion is 
>>> quite biased. Rails is the only web framework I've on since I started 5 
>>> years ago. So what do you think about the article.
>>>
>>> Cheers,
>>> Vedant.
>>>
>>
It's drivel. What difference does the market use of a tool make to people 
learning to code from a standing start. Unis still teach Logo and Fortran 
(among other esoteric anachronisms).

I've worked at (and set up) a fair share of code-bootcamps. Pandering to 
the "employers want Java" camp just causes the "employers want .Net" camp 
to scream louder.
The fact of the matter is, the students need to learn to code. Ruby is a 
good language for that (as are others), and whether or not it's a saleable 
skill after 10/12/14 weeks of study is irrelevant. The students on the boot 
camps are taking the first steps in learning to code - often from having 
never *ever* tried to code before - and if they get a job at the end of the 
course that they need to be familar with Java (or any other language) for, 
at the level they're at, it's a trivial task for them to come up to the 
same level they are at in whatever language they studied on their boot camp.


 

-- 
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/08fafaa9-0868-4276-be8c-de93d1d6b604%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Time to flounce...

2012-09-13 Thread Michael Pavling
Well, it's been a lovely few (four, I think?) years on the RailsTalk
list, but I'm unsubscribing now (and I didn't want to just fade out
the side-doors like so many names before).

I'm still working with Rails (and will continue to while the contracts
are around), but I can't take the volume and quality of emails from
this list any more.
I offer huge respect to the handful of posters that continue to fight
to keep the head of RailsTalk above water - I sincerely hope you win.

If you want to get hold of me, please connect on Google+ or LinkedIn,
or feel free to email direct. But I shan't be receiving list emails
any more.

ATB
Michael

-- 
You received 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: 15min of mentorship asked

2012-09-11 Thread Michael Pavling
On 11 Sep 2012 13:59, Pj M. li...@ruby-forum.com wrote:

 Hi there,

 I'm operating on a windows machine.
 However the kind of advice I'm looking for is not so technical in nature
 that I need advice how to get RoR running on my machine.

 With the help of AWDWR I already built the depot app on my machine. Now
 I'm looking for tips to get the most out of the language in 20 days.


Spend the first two days installing and familiarising yourself with Ubuntu
and RVM ... it'll repay itself many times over in future savings.

-- 
You received 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] misleading variable value

2012-09-10 Thread Michael Pavling
On 10 September 2012 02:41, John Merlino stoici...@aol.com wrote:
 I'm going to invoke action view base from console, passing a string
 object:

 1.9.3p0 :016  ActionView::Base.new('app/views')

 Look at the return value assigned to @view_paths. It should not be an
 array. It should be a PathSet object instance

It is a PathSet object - the easiest way to check this is to type:
  ActionView::Base.new('app/views').view_paths.class

What you see when you call ActionView::Base.new('app/views') is just
a string representation of the object. To assume when you look at the
to_s output in the console that the original object is what the to_s
produced is like looking at a black and white photograph and assuming
the subject of the photo was black and white.

-- 
You received 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] Object Efficiency

2012-09-10 Thread Michael Pavling
On 10 September 2012 05:03, rails2012 derek...@hotmail.com wrote:
 In my rufus config file, I have to call MyController.new.checkEmail.  Now I
 set it to run every 5 minutes.  So the system creates a new MyController
 instance every 5 minutes.  That's very inefficient right?

Normally it would be worth worrying about ten and hundreds of requests
a second... I don't think one every five minutes is going to cook the
processor.

 What else can I do?  Are there some advanced features in rails to mange
 object instance more efficiently?

What problems are you suffering? Have you measured the degradation in
performance on your system?


PS I would suggest that if Rufus is polling a method, that method
should not be on a controller. It should be on a model, or as a
stand-alone lib class.

-- 
You received 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] Math between Models

2012-09-04 Thread Michael Pavling
On 4 September 2012 18:58, Sachin S. li...@ruby-forum.com wrote:
 Class Model_1  ActiveRecord::Base
 ...
 has_and_belongs_to_many :model_2

 def some_method
 attr_1 * Model_2.find(model_2_id).attr_I_need
 end

If the relationship is HABTM, you won't have a model_2_id attribute to
find by, there should be a join table.

If you explain in a little more detail what problem you're trying to
solve with your relationship and the mathematical operation between
them, maybe a solution can be suggested.

-- 
You received 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] Is it a good idea for me to learn Ruby on Rails?

2012-09-01 Thread Michael Pavling
On 30 August 2012 13:33, Peter Hickman peterhickman...@googlemail.com wrote:
 For someone who says that they have very little programing knowlege
 you seem to have your mind already made up. Why did you even come here
 and ask your question if you already know the answer?

 So young, so set in your ways. Very sad.

http://tinyurl.com/44dznh6

;-)

-- 
You received 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] Extracting information out of a database column

2012-08-31 Thread Michael Pavling
On 31 August 2012 07:41, Joshua Baldock li...@ruby-forum.com wrote:
 I have an existing database that im building a rails app on top of. One
 of my columns 'message' is a long string that I would like to be able to
 query and split into various attributes to then be able to display each
 of those attributes in a view.

 I'm trying to implement this into the controller, but don't seem to be
 getting any where.

Which bit are you having trouble with? Accessing the legacy table?
Splitting the string? Displaying it in a view?

-- 
You received 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: Extracting information out of a database column

2012-08-31 Thread Michael Pavling
On 31 August 2012 08:20, Joshua Baldock li...@ruby-forum.com wrote:
 Splitting the string and then storing them as additional attributes to
 the instance variable that contains the rest of the selected table
 values.

Do you have an example of the string; the pattern that similar
instances would follow, and the components you need it split into?

-- 
You received 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: Re: Extracting information out of a database column

2012-08-31 Thread Michael Pavling
On 31 August 2012 08:59, Joshua Baldock li...@ruby-forum.com wrote:
 Message column and example message looks like this:

 The [user] is logged in via [hostname]

I assume the square brackets are not in the string, so that a real
string might look like :

 The administrator is logged in via michael-desktop
?

If so, you'll probably want to play with some string matching methods.
http://www.ruby-doc.org/core-1.9.3/String.html

match is a good place to start.

  class MyModel  AR::Base
# my model has a big string field called note_details, from
# which I want to extract the username and hostname values

def username
  note_details.match(/The (\S*) is logged in via (\S*)/)[1]
end

def hostname
  note_details.match(/The (\S*) is logged in via (\S*)/)[2]
end
  end

in the view you can access @my_model.username and @my_model.hostname
like any other attributes. If you have any issue with performance, you
could memoize the results, so you only run the .match once.

HTH

-- 
You received 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] Ensure that only one member of a collection has the current flag set

2012-08-29 Thread Michael Pavling
On 29 August 2012 16:13, Walter Lee Davis wa...@wdstudio.com wrote:
 I have a model that includes a :current boolean. The idea is that there are 
 many home pages that the admin is working on at any given time, but only one 
 is current at a time. At the moment, I have enforced this with the following:

 before_save :toggle_current

   def toggle_current
 if current?
   Home.where([current = ?  id != ?, true, self.id]).each do |home|
 home.update_attribute(:current, false)
   end
 end
   end

you could use update_all rather than iterate a collection, which
would only fire one SQL query.

-- 
You received 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: A Ruby Book (free to use)

2012-08-28 Thread Michael Pavling
On 28 August 2012 08:32, Karthikeyan A k li...@ruby-forum.com wrote:
 LOL! All know its absurd, don't u ppl have a sense of humour or
 something?

Is it supposed to be a joke book, or a tutorial?

-- 
You received 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] Where to store functions

2012-08-25 Thread Michael Pavling
On 25 August 2012 18:40, Dave Castellano li...@ruby-forum.com wrote:
 Generated questions are generated by a method I write.  When a
 generated question is picked, the method I wrote is called and it
 returns an instance of the question, its correct answer, and its
 explanation.  Each time the question is called it generates a slightly
 different version of the question. I plan to have hundreds of these
 methods.  Currently each is a separate file.


What do these generated methods look like? Are they very similar to
each other? Do they follow some sort of pattern? Could that be turned
into some form of configuration information?

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




[Rails] Quick Poll - Searching

2012-08-22 Thread Michael Pavling
What do you go for (for a Rails 2.x app...)? SearchLogic, or a little
scopes plugin?

I'm wondering whether I might just as easily get all my dynamic
searching done with TrixyScopes [1], or just plump for the market
leader.



[1] http://rubygems.org/gems/trixy_scopes

-- 
You received 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: How can I copy records from one table to another?

2012-08-14 Thread Michael Pavling
On 14 Aug 2012 04:38, ZeroModulus brlafreni...@gmail.com wrote:

 The number of records would vary widely.

 I thought of doing deleted tables because I had already thought of having
an attribute to mark a record as active, but figured I would have to write
an exclusion clause every time.

 Would there be a way to do this without having to write exclusion clauses
for every query?


Have a look at the acts_as_paranoid gem.

-- 
You received 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: How can I copy records from one table to another?

2012-08-14 Thread Michael Pavling
On 14 August 2012 11:12, Andrew Vit and...@avit.ca wrote:
 acts_as_paranoid simply adds a deleted_at flag, it doesn't move records to a
 separate table.

It does a *little more* than simply that...

 Something like acts_as_archive is a better equivalent.

The requirement to move them to another table was because the OP
didn't know how to flag records in the same table as deleted and
have them auto-magically ignored by finders, etc.

If the requirement is to archive them (which *isn't* the same as
softly deleting), along with the hassle of managing two sets of
tables... then acts_as_archived could be ideal.

-- 
You received 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] Where to store array(hash)?

2012-08-09 Thread Michael Pavling
On 5 August 2012 20:12, Дмитрий Снегирев rikk...@gmail.com wrote:
 I have hash:

 {default_list = {
 ws = 15,
 ret= 50},
 ret_discount = {
 5 = 5000,
 10=1,
 15=15000,
 20=3   }}

 Where better to keep it? Without database.

In memory?
In code?
As a constant?
In a yaml file?

-- 
You received 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] Pop quiz: Where do you watch for job postings?

2012-08-09 Thread Michael Pavling
On 9 August 2012 16:04, Ed W li...@wildgooses.com wrote:
 Hi all, I'm looking for some advice on where we should be putting an advert
 if we are looking to hire a full time rails developer? Or turning it around
 what websites (or mailing lists) do folks here use to if they feel the need
 for a change in view from their desk?

 A few details to narrow down scope since it might affect the advice,
 apologies in advance, trying to NOT make this an advert in itself:
 - We are based in London
 - Looking to hire local, permanent staff
 - Small company looking for self reliant people who can work independently

I look at posts on here, on LRUG and on Jobsite.

-- 
You received 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] How to encrypt Ruby script..

2012-08-07 Thread Michael Pavling
On 7 August 2012 11:36, Shrikant Lokhande lokhande.shrik...@gmail.com wrote:
 Its encripted but  its not running..

Why would it run? It's no longer a Ruby file, it's *encrypted*!

-- 
You received 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] How to encrypt Ruby script..

2012-08-07 Thread Michael Pavling
On 7 August 2012 11:46, Shrikant Lokhande lokhande.shrik...@gmail.com wrote:
 Yes its cool,,, but i want to run one ruby script and script having
 confidential info.
 So i need run  that in  encrypted mode.

Drip-feeding information like this is very frustrating.

http://www.catb.org/esr/faqs/smart-questions.html
(tl/dr: Please outline your problem, your attempted solutions, and the
errors you've had)

-- 
You received 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] Rspec

2012-08-04 Thread Michael Pavling
On 4 August 2012 06:30, honey ruby emailtohoneyr...@gmail.com wrote:
 Hi all i'm trying to learn Rspec  testing can anyone suggest me the best
 book to learn Rspec with good sample code.

The RSpec Book, maybe?

http://www.google.co.uk/search?q=rspec+book

Is your Google broken...

-- 
You received 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] How to remove a record if it is duplicate end sum values :val

2012-08-03 Thread Michael Pavling
On 1 August 2012 14:25, Esmerino Costa hakag...@gmail.com wrote:
 I have a hash like so:

That's not a hash, it's an array of hashes.

 What I would like to learn how to do is how to remove a record if it is
 duplicate end sum values :val.

  list.uniq!

-- 
You received 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] Testing Rails app

2012-08-03 Thread Michael Pavling
On 3 August 2012 06:32, honey ruby emailtohoneyr...@gmail.com wrote:
 Hi everyone i want to test a rails app and i have no idea on testing the
 rails app. Can any guide me how to test a rails app and what are the best
 way to test an app.

Have you tried http://www.google.co.uk/search?q=test+rails+app

Imagine that each of those results is someone answering your question
before you asked it. Read them, and then ask any specific questions
you have about implementing their advice.

-- 
You received 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] Polymorphic one-to-one associations in Rails 3.2 - what's the correct Rails way?

2012-08-03 Thread Michael Pavling
On 1 August 2012 02:17, Neil Mowbray neil.timothy.mowb...@gmail.com wrote:
 Unless I'm being dumb I cannot find anything on Google search or in the
 Rails books on how to create a one-to-one polymorphic association
 (as apposed to a one-to-many polymorphic association).

Change the has_many to a has_one, and you should have a 1:1 relationship...

 - Person
 generic concept (name, age, nationality, etc) which I want to attach
 polymorphically to concrete models suchs

 concrete class contain additional type specific information which I do not
 want nullable hence STI is not desirable
 and would result in a sparse table.

I would still consider STI for this kind of situation, but I'd give
each subclass a different association to the specific information for
that model, which would keep the DB nice and 'clean' (I did it
yesterday with Vehicles, and sub-classes for Car, Truck, Bus,
Motorbike, etc,)

class Person  AR::Base
end

class Staff  Person
  # employee number, start date, etc
  has_one :staff_details
end

class Mother  Person
  # can't imagine what info mother would need, but there's support for it
  has_one :mother_details
end

class Child  Person
  # what does a child need differently?
  has_one :child_details
end


Of course, the problem with this approach is what happens when you
have a staff member who is a mother? You'd need two records for them
(it's easy for me; a Car can't also be a Motorbike :-)
In this event you would be better coming from a different angle (like
a has_many :employments to determine whether a Person is staff or
not, and a has_many :parentings to figure whether they're a mother
or father)

HTH

-- 
You received 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] Integration of barcode Scanner or Reader into Application

2012-07-31 Thread Michael Pavling
On 31 July 2012 08:13, saritha chakilala li...@ruby-forum.com wrote:
 Can any one help how to integrate barcode reader into my Application.

 What I want actually is that,
By Capturing the value of barcode(registrtion_id) all other fields of
 that particular record need to autofill.

 ***I Am Looking For Your Valuable Reply **8

 Thanks in Advance.

Most barcode scanners are just another type of input device (like a
keyboard or mouse). When they scan, they send the series of digits
that the barcode represents to the computer as keyboard input - just
as if the user had typed them.

All you need to do is set up a form with a barcode number input
field, which is observed for any changes. That value can be posted to
your app and you can return whatever response you want.

If you want to get funky, depending on the features of your scanner,
you can set the scanner up to send a special character code before it
sends the rest of the characters, and you could use javascript to
watch out for the special character, and capture everything that comes
after...

-- 
You received 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] update_attributes clears password

2012-07-30 Thread Michael Pavling
On 30 Jul 2012 18:14, jsnark s...@monmouth.com wrote:

 I have a database table that contains encrypted passwords along with
other information relating to users.  When I do an update_attributes
operation on a row in the table with a hash that does not contain a
password, the password gets reset to the empty string.  How can I stop this?

Remove the password key/value pair from the params hash before the
update-attributes call if the password value is blank.

-- 
You received 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] update_attributes clears password

2012-07-30 Thread Michael Pavling
On 30 July 2012 20:23, jsnark s...@monmouth.com wrote:
 The hash does not contain a password key/value pair.  In spite of this, the
 password is set to the empty string.

What filters run in the model? What observers are operating?
It would be worth setting a breakpoint at your update_attribute line
and following through from there to see what happens to your password
attribute.

-- 
You received 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] update_attributes clears password

2012-07-30 Thread Michael Pavling
On 30 July 2012 22:39, jsnark s...@monmouth.com wrote:
 I understand the problem now, but I do not see the solution.  The model has
 a before_save filter that is causing the password to be reset.  How do I
 stop this on an update?

The same way I said before - only run it if the password has been populated:

   def encrypt_password
 self.encrypted_password = encrypt(self.password) unless
self.password.blank?
   end

But you will probably need to add same validation to ensure there is
an encrypted_password - otherwise it would be possible to create
accounts with blank passwords...

-- 
You received 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] Same name action and attribute in a model

2012-07-27 Thread Michael Pavling
On 27 July 2012 07:22, Sumit Srivastava sumit.theinvinci...@gmail.com wrote:
 I have been following following tutorial to make a user login session.
  http://www.aidanf.net/rails_user_authentication_tutorial

 I used the following action to encrypt the password.

   def password
 #debugger
 @password1=pass
 self.salt = SecureRandom.hex(10) if !self.salt?
 self.password = User.encrypt(@password1, self.salt)
   end


 but when it is called following error is generated.

 SystemStackError (stack level too deep):
   app/models/user.rb:26:in `password='
   app/models/user.rb:27:in `password='
   app/controllers/user_controller.rb:31:in `new'
   app/controllers/user_controller.rb:31:in `createuser'

Which (if any) of those lines is line 26 in your UserController? What
does the User.encrypt method look like?

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




Re: [Rails] Same name action and attribute in a model

2012-07-27 Thread Michael Pavling
On 27 July 2012 08:07, Michael Pavling pavl...@gmail.com wrote:
 Which (if any) of those lines is line 26 in your UserController? What
 does the User.encrypt method look like?

Ignore me... I can't even read your error message properly myself.

 I used the following action to encrypt the password.

   def password
 #debugger
 @password1=pass
 self.salt = SecureRandom.hex(10) if !self.salt?
 self.password = User.encrypt(@password1, self.salt)
   end


Right... so where does the value of pass come from? Is there a
method that returns it?

In the (six year old) tutorial you're following, the method is:

  def password=(pass)
@password=pass
self.salt = User.random_string(10) if !self.salt?
self.hashed_password = User.encrypt(@password, self.salt)
  end

but you've changed it to not take any attributes, and to update
self.password rather than self.hashed_password. It would probably
help a little to post a bit more (all) of your model. Also, I'm
curious why, if you're following a tutorial, would you change large
chunks of the functionality? If you implement it exactly as described,
does it work?

-- 
You received 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] Same name action and attribute in a model

2012-07-27 Thread Michael Pavling
On 27 July 2012 10:42, sumit srivastava sumit.theinvinci...@gmail.com wrote:
 This is the complete model. I am trying to encrypt the password.
   def self.hashedpass(login, pass)
 u=find(:first, :conditions=[login = ?, login])
 return nil if u.nil?
 return u if User.encrypt(pass, u.salt)==u.hashed_password
 nil
   end

You compare the hashed user input with the u.hashed_password attribute here...

   def passwordtext=(pass)
 #debugger
 @password1=pass
 self.salt = SecureRandom.hex(10) if !self.salt?
 self.password = User.encrypt(@password1, self.salt)
   end

...but here you're setting the password attribute - so is there a
hashed_password attribute on the user? And if so, how is it set?


 I am not exactly following the tutorial. I have customized things according 
 to my requirements.

Your requirement was to have a non-working password hashing process?!
- as it seems that's all your customization has achieved.
What was wrong with the tutorial that didn't work for 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Same name action and attribute in a model

2012-07-27 Thread Michael Pavling
On 27 July 2012 11:13, sumit srivastava sumit.theinvinci...@gmail.com wrote:
 During customizations I have used password as the column where encrypted
 password shall be saved. So I created my own attr_accessor, i.e.,
 passwordtext. I have named the password_field_tag in my form as
 passwordtext. But when I do so, it is not executed. Instead if I rename the
 password_field_tag and the attr_accessor as password only, it is executed
 but the stackerror comes in.

All of this info would have been very helpful in your OP anyway...

... what happens when you try this:

  def passwordtext=(pass)
@passwordtext=pass
self.salt = User.random_string(10) if !self.salt?
self.password = User.encrypt(@passwordtext, self.salt)
  end

If it's still overflowing, can you post the error message again (since
the model has changed since your first post this morning) and the
corresponding method from the controller, as it might be something in
there behaving weirdly.

-- 
You received 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] Same name action and attribute in a model

2012-07-27 Thread Michael Pavling
On 27 July 2012 11:37, sumit srivastava sumit.theinvinci...@gmail.com wrote:
 This is what I receive,

 SystemStackError (stack level too deep):
   app/models/user.rb:26:in `password='
   app/models/user.rb:27:in `password='
   app/controllers/user_controller.rb:31:in `new'
   app/controllers/user_controller.rb:31:in `createuser'

 Here createuser action is used to store the user info into database.

 Line 31 reads as follows,
 @user = User.new(params[:user])

I would put a breakpoint on that line and then keep stepping into
until you see where it's looping :-/

-- 
You received 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] Same name action and attribute in a model

2012-07-27 Thread Michael Pavling
On 27 July 2012 11:52, sumit srivastava sumit.theinvinci...@gmail.com wrote:
 That might be another solution. But what I am trying to know is why isn't
 this method working. And how is the action def password=(pass)  actually
 being called. Because I didn't see any exclusive line where it is being
 called. My analysis says it is being executed because of the attr_accessor
 and having name same as that of the column password.

Which accessor? The only accessor you have is passwordtext.

-- 
You received 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] Same name action and attribute in a model

2012-07-27 Thread Michael Pavling
On 27 July 2012 17:31, sumit srivastava sumit.theinvinci...@gmail.com wrote:
 Right now I have renamed it to passwordtext but originally it was password.
 I wrote about its behavior when named as password.

Okay... so what help is that? What difference does what something
*used* to be make?! If you have a problem *now* it's only a concern
what the settings are *now*.

Have you followed through in the debugger to see what's going on?

-- 
You received 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: Rails' inflections are messy

2012-07-19 Thread Michael Pavling
On 19 July 2012 20:48, Colin Law clan...@googlemail.com wrote:
 On 19 July 2012 20:07, Linus Pettersson linus.petters...@gmail.com wrote:
 At least they should fix the ones that are incorrect...

 Octopus.pluralize should return Octopuses and NOT Octopi... :)

 But then all those applications that rely on the current pluralisation
 of octopus would break when upgraded.  Innumerable applications around
 the internet would come to their knees.

:-)

Surely all those sites' developers could just override the inflector
back to what it used to be, and get on with all the other tasks they
need to complete to upgrade to Rails4?

-- 
You received 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] Nil Class

2012-07-16 Thread Michael Pavling
On 16 July 2012 20:52, Adnan adnan.a...@gmail.com wrote:
 I've a field in my two db tables called username. when I try to match post
 author and current username for editing a post
 @movies.username==current.name in my moviescontroller. It showed nil class
 or method. Why this is showing??Any ideas??

Check what the values for both @movies and current are at this
line. What are they?

-- 
You received 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] error in runtime controller#view

2012-07-04 Thread Michael Pavling
On 4 July 2012 07:14, Abhishek Sharma asharma...@gmail.com wrote:
 class PageController  ApplicationController

 before_filter :find_subject

   def new
 @page = Page.new(:subject_id = @subject.id)
 @page_count = @subject.pages.size + 1
 @subjects = Subject.order('position ASC')
   end

   private
   def find_subject
 if params[:subject_id]
   @subject = Subject.find_by_id(params[:subject_id])
 end
   end

 end

You're calling find_subject on a before_filter, and it may or may not
populate a @subject object depending on whether there's a param value.

But your action then goes on to expect there to definitely be an
@subject instance variable. Put a breakpoint in find_subject, and see
what the parameter values are.

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



Re: [Rails] Re: variable symbol

2012-07-03 Thread Michael Pavling
On 3 July 2012 13:04, Aleksey V Zapparov i...@member.fsf.org wrote:
 I don't speak Deutsch, but I guess I understood you. Sorry it was my
 mistake (copy-paste is evil):

 us.bslnk.send :#{tst}= false

You're probably going to need a comma in there to separate the
parameters being passed to .send

  us.bslnk.send :#{tst}=, false

It may be clearer in this instance to be explicit with parantheses:

  us.bslnk.send(:#{tst}=, false)

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



Re: [Rails] will_change!

2012-06-27 Thread Michael Pavling
On 27 June 2012 10:56, kengsreng tang li...@ruby-forum.com wrote:
 Dear all
 model person
  id: 1,
  name: test
 end
 i need some explanation about name_will_change!

you're not the only one.

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



Re: [Rails] E-Books for RoR 3

2012-06-27 Thread Michael Pavling
On 27 June 2012 12:12, Ankit Kipl ankit.k...@gmail.com wrote:

WHAT ARE YOU DOING SENDING 12Meg FILES TO THIS LIST?

Not to mention that it's copyright material... Ryan may be in contact
with your ISP shortly

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



Re: [Rails] Unit Testing SQL

2012-06-22 Thread Michael Pavling
On 22 June 2012 15:07, Gurdipe Dosanjh rhomobilea...@gmail.com wrote:
 What is the best way to unit test hard coded sql in a rails application.

You don't test SQL, you test methods. Whether the method gets it's
results through ActiveRecord, raw SQL, or fairies rummaging around the
hard drive, it's irrelevant to the tests. They should just be testing
that the expected values are returned by the method.

So the answer to your question may be move the SQL to be wrapped by
methods, and test those, but without seeing some source code it would
be hard to say.

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



Re: [Rails] Re: why use rescue nil?

2012-06-20 Thread Michael Pavling
On 20 June 2012 01:55, John Merlino stoici...@aol.com wrote:
 ok I thought it would return nil

It would take 30seconds to try it out in a console...

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



Re: [Rails] Re: Associations join

2012-06-20 Thread Michael Pavling
On 20 June 2012 08:51, Timen E. li...@ruby-forum.com wrote:
 #card_controller.rb
 class CardController  ApplicationController
  def show
    @card = Card.all
  end
 end

 h1Card#show/h1
 pFind me in app/views/card/show.html.erb/p
 %= @card.user %

 undefined method `user' for #Array:0x3c81ac8
 Extracted source (around line #3):

@card is a collection of cards (that's how you populate it in the
show action. If it needs to be a single card, you need to find it by
ID (or some other attribute), if it's supposed to be a collection of
every card, you need to iterate it in the view and print the user for
each card.

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



Re: [Rails] how to update a table which is connected with joins

2012-06-13 Thread Michael Pavling
On 13 June 2012 08:31, hanish jadala emailtohoneyr...@gmail.com wrote:
 hi all help me out guys


 thanks in advance

 On Tue, Jun 12, 2012 at 3:07 PM, hanish jadala emailtohoneyr...@gmail.com
 wrote:

 no with our changing the relationship can i update values.


We did - you refused to do it :-/

Let's just restate your position: You want to have a habtm join, with
extra information in the join table. This type of join typically does
not have a model, and thus no way of updating those extra fields
(although a feature of Rails does/did extend columns in the join
table to both sides of the association).
You don't want to add a new model and join through it (the way it
would be done normally).
So you see the circular problem you have...

Let's take one step back; rather than demanding that people help you
out, maybe you can explain *why* you don't want to change your
association...

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



Re: [Rails] how to update a table which is connected with joins

2012-06-13 Thread Michael Pavling
On 13 June 2012 10:20, hanish jadala emailtohoneyr...@gmail.com wrote:
 hi Michael Pavling i can not change my
 relationship because i have used in many other places if i change
 relationship i have to make more changes in my app that is y i can not
 change my relationship.

So instead of doing a refactor to support the new functionality you
want (a moderately fiddly job to change many other places - but an
opportunity to DRY them up...), you're going to plan to bodge in
something that will make it practically impossible to ever refactor
this area of code in the future. This will make any future
functionality changes in this area an absolute nightmare.

Google technical debt.

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



Re: [Rails] I can't install ruby on rails on my mac - Sorry I know it's been posted 1 million times before

2012-06-13 Thread Michael Pavling
If it's been posted a million times before, have you read all the
responses to those questions?...

On 13 June 2012 11:33, blakeh92 handson.bl...@gmail.com wrote:
 This is the guide i've been following:

 http://hivelogic.com/articles/ruby_rails_lighttpd_mysql_tiger/

You're following a 7-year-old thread guide?! Can you not find one
that's a bit more recent?

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



Re: [Rails] how to update a table which is connected with joins

2012-06-12 Thread Michael Pavling
On 12 June 2012 10:31, honey ruby emailtohoneyr...@gmail.com wrote:

 hi all there are two tables Student and Batch in there model i have
 has_and_belongs_to_many :graduated_batches, :class_name = 'Batch',
 :join_table = 'batch_students' in Student table
 i have added a new column to batch_students table and i want to update the
 value in batch_students table. How can i update values in batch_students
 table where there is no model for that table so that i can update
 directly.how to update table which is in joins.


Sounds like you want to change those habtm relationships to has_many
:through = :batch_students

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



Re: [Rails] Re: if else statement

2012-06-11 Thread Michael Pavling
On 11 June 2012 10:19, Paul McGuane li...@ruby-forum.com wrote:
 thanks for the tips, i cleaned up the code a bit, and used some other
 logic which produced this

 def win_lose_tie
    if self.for.to_i == self.against.to_i then
      :tie
    elsif self.for.to_i  self.against.to_i then
      :win
    else
      :lose
    end
  end

So you turned a Ruby two line method into a PHP 7-liner? If you prefer

Well, as long as you see the direction the code should go, you can
always make it more Ruby later ;-)

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



Re: [Rails] installing ruby on rails 1.9.3 on windows 7

2012-06-11 Thread Michael Pavling
On 11 June 2012 19:19, nishant g. li...@ruby-forum.com wrote:
 C:\Sites\railsinstaller_demorails s
 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs/run
 times.rb:51:in `autodetect': Could not find a JavaScript runtime. See
 https://gi
 thub.com/sstephenson/execjs for a list of available runtimes.

 Please guide me what to do..

Install a javascript runtime?

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



Re: [Rails] Re: if else statement

2012-06-10 Thread Michael Pavling
On 10 June 2012 01:12, Paul McGuane li...@ruby-forum.com wrote:
 Hi  Michael,
 I have tried the code you suggested, though all i seem to get is every
 result as a tie. this is what I have in my

 #model
 def win_lose_tie
    return :tie
    if if schedule.for.to_i == schedule.against.to_i
         schedule.for.to_i  schedule.against.to_i ? :win : :lose
       end
    end

  end

Hiya,

The code I posted was a rough, un-run, first draft typed straight into
the email client, but even so, I did a little re-arrangement and
DRYing while composing, and left an extraneous if on the first line
of win_lose_tie. This is what it should look like (the if condition at
the end of the line is a modifier, or guard - not a construct that
PHP supports AFAIK ;-)

  def win_lose_tie
return :tie if schedule.for.to_i == schedule.against.to_i
schedule.for.to_i  schedule.against.to_i ? :win : :lose
  end

Bear in mind that I haven't run it - so it may need a little
debugging. The intention of my post is that you see more clearly the
direction the code should be heading towards (rather than having huge
logical constructs in your views).

 i even tried what you would do in php and had a variable set us :result

To be honest, I don't really see how trying in PHP is going to go
any way to solving a problem you have in Ruby - it's certainly not one
of the first debugging steps I would recommend :-/

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



Re: [Rails] Modeling one way associations

2012-06-09 Thread Michael Pavling
On 9 June 2012 16:45, Jason Walsh li...@ruby-forum.com wrote:
 I am working on a project where I have a Process object that references
 a Node object.  I have tried adding a node_id column in the Process
 table and created an has_one relationship in the Process model.

Change that relationship definition to a belongs_to rather than a has_one.

http://guides.rubyonrails.org/association_basics.html

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



Re: [Rails] if else statement

2012-06-09 Thread Michael Pavling
On 9 June 2012 17:26, Paul McGuane li...@ruby-forum.com wrote:
 undefined method `' for nil:NilClass
 Extracted source (around line #47):

The error is telling you that the thing you are calling greater than
on is nil.
Looking at line 47, that thing is schedule.for - this value,
although you *think* it may be an integer is nil.

First off, look into debugging your app to get to the bottom of these
issues faster for yourself:
http://guides.rubyonrails.org/debugging_rails_applications.html

Secondly, a bodge fix would be to call to_i on the values before you
compare them:
% if schedule.for.to_i  schedule.against.to_i %

Thirdly. this sort of logic should really live in the model, or a
helper (or split between both), certainly not in the view.

#Schedule model
def win_lose_tie
  return :tie if if schedule.for.to_i == schedule.against.to_i
  schedule.for.to_i  schedule.against.to_i ? :win : :lose
end

#helper
def win_lose_tie_display(value)
  case value
  when :win
W
  when :lose
L
  when :tie
T
  else
unknown win/lose/tie value
  end
end

#view
 strong%= win_lose_tie_display(schedule.win_lose_tie) %/strong

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



Re: [Rails] Modeling one way associations

2012-06-09 Thread Michael Pavling
On 9 June 2012 17:51, Colin Law clan...@googlemail.com wrote:
 @Michael, perhaps we should work in shifts.

 Colin

:-D

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



Re: [Rails] Re: Problem with array of hashes

2012-06-05 Thread Michael Pavling
On 5 June 2012 19:19, cyber c. li...@ruby-forum.com wrote:
 Yah i get it. I wanted to convert this array of hash into an array of
 class objects. How do i do that in ruby?

They are class objects - hashes are instances of Hash class ...

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



Re: [Rails] Re: validation not called on create, only update

2012-06-01 Thread Michael Pavling
On 1 June 2012 04:31, flaps flaps2...@gmail.com wrote:
 THanks for your response. The validation methods are not called on a
 create, allowing the save method to be called, unprotected. I dont
 want the save to be called let alone fail.

Is there any chance you could post your controller code. I wonder
whether you've got a .save false in the create action...

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



Re: [Rails] warning: already initialized constant

2012-05-30 Thread Michael Pavling
On 30 May 2012 10:44, Gurdipe Dosanjh rhomobilea...@gmail.com wrote:
 Loading development environment (Rails 2.1.0)
 /denorm_brag_report.rb:423: warning: already initialized constant
 MAIN_CATEGORIES

Does your code include the denorm_brag_report.rb file more than once?

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



Re: [Rails] warning: already initialized constant

2012-05-30 Thread Michael Pavling
On 30 May 2012 12:07, Gurdipe Dosanjh rhomobilea...@gmail.com wrote:
 I have checked and its not been called anywhere else, but may be im missing
 something simple

 it always gives a warning on the last entry of the set of values  in
 assigned to the constants

I would recommend putting a breakpoint on the line that defines the
constant, and then the second time it gets there have a look at the
call stack to see how it's ending up there twice.

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



Re: [Rails] Rails developer required.

2012-05-23 Thread Michael Pavling
On 22 May 2012 09:00, cmittal cmitta...@gmail.com wrote:
 what's wrong with this?

It doesn't demonstrate *any* willingness by the OP to put in effort
into recruiting for their position. Typically, the stage of trying to
attract people is when you try your hardest to put on a good show; so
if this is an indication of what it's like when they're on best form,
imagine what actually working there will be like...


More measurably, it contains no information about the role's
requirements, the location, the employer's expectations, the hours of
work, the remuneration... let me ask you - do you think there might be
anything good about the ad?

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



Re: [Rails] Rails developer required.

2012-05-22 Thread Michael Pavling
On 21 May 2012 22:57, Suraj B. li...@ruby-forum.com wrote:
 If you are experienced rails developer please let me know.

worst

job

ad

ever

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




Re: [Rails] loop in rails view

2012-05-22 Thread Michael Pavling
On 22 May 2012 15:36, amvis vgrkrish...@gmail.com wrote:
 basically  with that if condition, i need to show different div,

 % @update_coupon.each do |doc| %
       % if  doc[value] == 2 %
          //code
       %elsif  doc[value] == 5 %
         //code
       %elsif  doc[value] == 6 %
        //code
       %end%

 %end%

You need a case statement as a starting point:

http://stackoverflow.com/questions/948135/how-to-write-a-switch-statement-in-ruby

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



Re: [Rails] can someone explain how map! / connect! works in this case?

2012-05-18 Thread Michael Pavling
On 18 May 2012 04:57, Christopher D. li...@ruby-forum.com wrote:
 ary = [0,1,1,1,1,3]
 ary.map! { |num| %w(zero one two three)[num] }

 I just don't get it, how does it know which value to write out?

you're taking the numbers 0,1,1,1,1,3 and for each of them you're
populating an array with the values from another array at the index
that corresponds to the number you're operating on at the time.
It doesn't know which number to write out, you're telling it to go
get whatever element is at the index.

 If I
 change the array number say to 10 instead of three and change the word
 three to ten in the block it comes as nil...

If you change one of them to 10, then the map is not going to find
an element in your %w(zero one two three) array at index 10, so it
returns nil.

 is there something
 special about 1..3 that I am missing?

No, but it would probably be best to familiarise yourself with the
Enumerable methods' documentation. Or maybe go through the Ruby koans
to experiment.

BTW What on earth are you trying to achieve with this code?

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



Re: [Rails] Ror code please just help me in findng solution

2012-05-16 Thread Michael Pavling
 On May 16, 2012, at 11:05 AM, Prajwal B. wrote:
 or else even i can talk vulgar than you see how this
 rascal.

*ker-splunk*
Another one in the ignore filter pool...

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



[Rails] Rails, you are so nice

2012-05-16 Thread Michael Pavling
Just feel like it's time to put some love out there.

I've spent the day chopping up years-old scripts that did lots of
querying and looping (pesky PHP coders trying to write Ruby...) and
have replaced tonnes of methods with a few nicely chained named_scopes
(I'm still mired in Rails2.1 for this project).

The reports run ten-times quicker; the code is a tenth of the size;
it's all beautiful Ruby, and all's good in the world :-)


Thanks, Matz, DHH, Koz, Katz, et al.

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



Re: [Rails] how to prevent the user from accessing the app.after logout with back button(rails only)

2012-05-10 Thread Michael Pavling
On 10 May 2012 07:54, honey ruby emailtohoneyr...@gmail.com wrote:
 after logging out of my site if i click back button it is going back
 how can i restrict this problem

It's a browser caching issue, so you need to tell the browser not to cache.

http://stackoverflow.com/questions/711418/how-to-prevent-browser-page-caching-in-rails

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



Re: [Rails] how to prevent the user from accessing the app.after logout with back button(rails only)

2012-05-10 Thread Michael Pavling
On 10 May 2012 08:46, hanish jadala emailtohoneyr...@gmail.com wrote:
 thanks for your reply i have added your code and i checked it. if i click
 back button after logout it is still going back to app but it is give me the
 error 

 undefined method `username' for nil:NilClass it shows it going back to app.

It's not my code - it's sample code from the Internet.
Your error is now in your code - probably in the handling of
controller actions when users are not logged in.

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



Re: [Rails] how to encryption and decryption a string or integer in ruby

2012-05-10 Thread Michael Pavling
On 10 May 2012 11:01, honey ruby emailtohoneyr...@gmail.com wrote:
 i want to encrypt and decrypt a number or string in RoR. is there any
 gem or plug-in for that.

http://lmgtfy.com/?q=ruby+encrypt+decrypt

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



Re: [Rails] Sorting of users depending on

2012-05-09 Thread Michael Pavling
On 9 May 2012 07:34, Ajit Teli li...@ruby-forum.com wrote:
  Currently I am
 sorting (order) users depending on email id. I would like to sort the
 users depending on checkbox status so that selected (checked) users will
 be listed first and then other emails will be listed in the order of
 email.

The first step is to get that finder out of the view, and move it into
the User model. Then you can call it on the @current_user instance and
do all of your sorting and shuffling in one place:

Class User  AR::Base
  def accessible_users
return [] unless role == excelfore
User.all( :order = :email, :conditions = ( [role !=
'excelfore'] ) ).sort_by { |u| u.receiving_group_email? }
  end

  def receiving_group_email?
# some calculation here that returns whether or not users are at
the top of the list - or even better, move it into the conditions of
the finder...
  end
end

# in the view
% @current_user.accessible_users.each_with_index do |u,i| %  etc

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



Re: [Rails] Re: does it really achieve the productivity advantages it claims?

2012-05-09 Thread Michael Pavling
On 9 May 2012 10:46, Peter Hickman peterhickman...@googlemail.com wrote:
 I'm pretty sure that no one ever claimed that Rails makes you psychic.

I could sense you were gonna type that...

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



Re: [Rails] Re: Sorting of users depending on

2012-05-09 Thread Michael Pavling
On 9 May 2012 11:51, Ajit Teli li...@ruby-forum.com wrote:
 Can I do it by using sorttable.js ? I have included table headers,
 sorttable.js. And also I have changed the table class to
 class=sortable. But it is not working.

No idea - that's nothing to do with Rails AFAIK - it's all front-end
stuff; JS manipulation of data that's been sent to the browser.

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



Re: [Rails] validating input values(integer)

2012-05-04 Thread Michael Pavling
On 4 May 2012 08:16, Soichi Ishida li...@ruby-forum.com wrote:
 But interestingly, if I input, say, 'this' in the input form, it directs
 to the next page and the '0' (an integer, though) value is inserted in
 the DB.  I do not have any default value to 'price'.

If you pop open a Rails console and type:

  'this'.to_i

What result do you get?

Yep - zero is an integer. Rails casts the values from params to map to
the DB fields, so if you want validate the values the user typed
rather than the values Rails has translated them to, you may need to
write a custom validation and check the before_typecast value.

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



Re: [Rails] Re: validating input values(integer)

2012-05-04 Thread Michael Pavling
On 4 May 2012 09:41, Soichi Ishida li...@ruby-forum.com wrote:
 1.9.3-p0 :008  'this'.to_i
  = 0
 1.9.3-p0 :009 

 It's zero...it does not seem good at all ;)

That's a different thread entirely ;-)

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



Re: [Rails] Re: Re: Hosting application on private network.

2012-05-03 Thread Michael Pavling
On 3 May 2012 13:10, Ajit Teli li...@ruby-forum.com wrote:
 Fy final idea is to host the application worldwide. All the http
 requests to public ip (122.166.7.181) with port 8050 should be directed
 to my system and users should be able to browse the app. I have
 configured the router for port-forwarding. But it is not working.
 If you know how to host the web application then suggest me.

This sounds like an Apache/router issue, not a Rails issue. If you can
get a flat, HTML-only site working internally, then a Rails app should
be able to slot into the configuration.

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



Re: [Rails] Why I have to set two unnecessary params in controller action after i send form_tag?

2012-05-03 Thread Michael Pavling
On 3 May 2012 15:16, regedarek dariusz.fins...@gmail.com wrote:
 https://gist.github.com/2585733

 This is my code.

send is an critically important method in Ruby - probably best to
name your action something else.

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



Re: [Rails] CSV Import Issue

2012-05-01 Thread Michael Pavling
On 1 May 2012 17:29, Rahul B. li...@ruby-forum.com wrote:
 I am getting an error NoMethodError.

The error would have told you which line and file the error was on. If
you can share that information, then it may be easier to help suggest
solutions.

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



Re: [Rails] Is my developer dodgy?

2012-04-27 Thread Michael Pavling
On 27 April 2012 14:57, Emanresu craiglba...@gmail.com wrote:
 I need some help...

Didn't you post this three days ago?

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



Re: [Rails] Missing Method as Filter

2012-04-26 Thread Michael Pavling
On 26 April 2012 00:31, Christopher D. li...@ruby-forum.com wrote:
 User.find_by_username(Tom)? 1 : 0

 How would I find out Tom's corresponding id?

 For example I'm looking for something along the lines of:
 User.find_by_username(Tom).id

   (user = User.find_by_username(Tom)) ? user.id : 0

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



Re: [Rails] Re: To developers of Rails: Feeble documentation - weakness of Ruby and the Ruby on Rails (2nd edition)

2012-04-26 Thread Michael Pavling
2012/4/26 Karthikeyan A.K mindas...@gmail.com:
 I strongly feel Rails community should have a good documentation like PHP
 people have. that will surely increase number people who want to learn and
 use Rails.

Again *which* bit of documentation needs to be better... how many
times have you honestly been confounded by not finding something in
the docs? (and when you did, did you contribute to fill the hole?)

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



Re: [Rails] Re: To developers of Rails: Feeble documentation - weakness of Ruby and the Ruby on Rails (2nd edition)

2012-04-26 Thread Michael Pavling
On 26 April 2012 14:13, Scott Ribe scott_r...@elevated-dev.com wrote:
 On Apr 26, 2012, at 1:36 AM, Michael Pavling wrote:

 Again *which* bit of documentation needs to be better

 Nearly every frickin' time I look something up. Rails docs are really awful 
 compared

Now, this is where I'm flummoxed, because I just don't find that. I've
learned loads from the docs and source. But I do agree that not
everyone works the same way, or learns the same way, and it may be
that the docs as they are are not right for a large section of the
readership. But this comes back to the thought that if there needs to
be a different style to some of the documentation, then those that
need it need to start writing it rather than just complaining about
it.

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



Re: [Rails] Re: To developers of Rails: Feeble documentation - weakness of Ruby and the Ruby on Rails (2nd editi

2012-04-25 Thread Michael Pavling
On 25 April 2012 06:03, Sergey Ezhov li...@ruby-forum.com wrote:
 There is a set of examples where people approached more responsibly to
 documentation creation, for example: http://www.yiiframework.com,
 http://kohanaframework.org, http://framework.zend.com/

There is an Agile methodology argument that documentation should be
written by those that need it. Perhaps you could pair with a developer
and help to contribute, as you have very clear ideas of what would be
useful.

 I suppose, they reflected on convenience of use of tools to developers.

From my own experience, I find that I can't necessarily write the
clearest documentation for the code I write; just like I can't do UI
design, colour-palette mixing, or a host of other associated skills.
The skill of being able to write good documentation isn't always going
to overlap with being able to write good code - so maybe the lack of
good docs is more down to a lack of people who are able to write the
docs contributing, rather than any malicious intent of the core
developers.

As and aside; if you compare the Rails core to lots of other
frameworks (particularly some of those written in PHP that you cite)
the source is a *lot* more self documenting when it's written well
in Ruby. And it's a million times better than *badly* written PHP. So
given the choice, I'd rather have good code with sparse docs, than
poor code with good docs.

YMMV

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



Re: [Rails] Re: To developers of Rails: Feeble documentation - weakness of Ruby and the Ruby on Rails (2nd editi

2012-04-25 Thread Michael Pavling
On 25 April 2012 09:50, Sergey Ezhov li...@ruby-forum.com wrote:

I assume that because you're using Ruby Forum, you're not quoting.
Please bear in mind that the forum is just a wrapper that some people
use to hide the mailing list. For those of us who use the mailing
list, un-quoted replies are barely legible.

 And how about a good documentary code and all as good documentation to
 it?

Of course, that's the ideal situation :-)
Which of those frameworks has that? ;-)

 For some reason developers of PHP weren't too lazy to create
 documentation design team.

Again, you're confusing PHP the language, with Rails the
framework. Ruby has *very good* (in my opinion) API documentation -
much better than the comment/discussion-ridden PHP documentation.

Let me just let you know, in case you were assuming, I'm nothing to do
with Rails - I'm just a developer like yourself. But I do wince when I
read phrases like too lazy, as that implies a concious decision - an
allegation that's liable to rile some people. I'm happy to give you
the benefit of the doubt, as you've said that English is not your
first language (although, I think you're making a great effort if
you're not using a translator *applauds*). But you haven't answered my
suggestion that if you think the core team are lacking in
documentation skills, could you help contribute?

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



Re: [Rails] Re: To developers of Rails: Feeble documentation - weakness of Ruby and the Ruby on Rails (2nd editi

2012-04-25 Thread Michael Pavling
On 25 April 2012 10:20, Sergey Ezhov li...@ruby-forum.com wrote:
 I don't know, what advantage is received by developers from popularity
 of language, from popularity of framework.

Again, you're posting without quoting, so I have no idea what you're
referring to.

 Really very many people stop and leave from Ruby and Ruby on Rails use
 only in the absence of good documentation.

What documentation *is* missing? There are dozens of getting started
with Rails books, and indeed, if you type that phrase into your
search engine of choice, you get a massive amount of results,
including:

  http://guides.rubyonrails.org/getting_started.html
  http://railscasts.com/episodes/310-getting-started-with-rails
  https://devcenter.heroku.com/articles/rails3

And let's not forget what I already referred to as the great Ruby API docs:
  http://www.ruby-doc.org/core-1.8.6/
  http://www.ruby-doc.org/core-1.8.7/
  http://www.ruby-doc.org/core-1.9.3/

And the very handy Rails API docs:
  http://api.rubyonrails.org/

So what *is* extra that is needed in your view? If you've got a great
idea, then awesome! Please contribute it, I'd love to see it.

 And you suggest to rush to study of source codes
 directly. It very much frightens off beginners.

No, I *didn't* suggest it (and if you'd quoted what I said, you would see it).
I said that *I* find well-written-source-code-with-poor-docs better
than poorly-written-code-with-good-docs, but I *never* said I agreed
with you that the Ruby/Rails docs are poor.
Personally, I think they're perfectly good, and the associated
contributions from the community are of varying quality, but generally
good/excellent. But I'm happy to discuss with you your disagreement.

There's always room for more tutorials... please contribute! :-)

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



Re: [Rails] Re: Re: To developers of Rails: Feeble documentation - weakness of Ruby and the Ruby on Rails (2nd e

2012-04-25 Thread Michael Pavling
On 25 April 2012 11:11, Sergey Ezhov li...@ruby-forum.com wrote:
 Try, for example, to find a method method_missing. Fail!

http://rubydoc.info/stdlib/core/1.9.3/BasicObject#method_missing-instance_method

example fail...

 How I can trust documentation in which methods about which I already
 know aren't described?

A null hypothesis.

 And the very handy Rails API docs:
   http://api.rubyonrails.org/
 Bad documentation! There are no descriptions of many classes, there are
 no descriptions of many methods, there are no descriptions of parameters
 of methods, there are no descriptions of ALL possible parameter values
 of methods.

*sigh* so write them... or ask about specific places where you're stuck.


Look, you're talking about things being difficult for beginners, and
then wave method_missing as an example - to play with that is pretty
serious meta-programming which will blow up horribly if you don't know
what you're doing. There *is* plenty of reference for *how* to use
method_missing if you look for it, even if it is not mentioned in the
core docs.

If you expect *everything* to be totally complete before you start
using it, then you're going to be disappointed (in life, not just in
Ruby/Rails). In all seriousness, if a few holes in documentation
frustrate someone so much that they stop and leave from Ruby and
Rails then maybe it wasn't for them in the first place - it takes all
sorts to run the world, and everything is not for everyone :-/

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



Re: [Rails] Re: To developers of Rails: Feeble documentation - weakness of Ruby and the Ruby on Rails (2nd editi

2012-04-25 Thread Michael Pavling
On 25 April 2012 15:36, Kevin Bedell kbed...@gmail.com wrote:
 On Tue, Apr 24, 2012 at 4:10 PM, Robert Walker li...@ruby-forum.com wrote:
 Languages are MUCH smaller in scope than frameworks.
 According to ohloh.net, rails has about 250,000 lines of code, while
 Ruby recently eclipsed 1 million lines of code.

scope != LoC

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



Re: [Rails] Re: beginning_of_month problem

2012-04-12 Thread Michael Pavling
On 12 April 2012 13:41, Colin Law clan...@googlemail.com wrote:
 Life would be much simpler if the world did not go round.

Or if we decimalised time ;-)

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



Re: [Rails] Re: What Model Association?

2012-04-05 Thread Michael Pavling
On 5 April 2012 01:54, Mark P. li...@ruby-forum.com wrote:
 I just realized CarWashStation might be misleading. Each station refers
 to one activity location that the car mush move through per wash. A
 few example instances might be:

  - Soap Application Station
  - Bristle Brush Station
  - Wax Station
  - Dry Station

That sounds like a CarWashing should have a state-machine to manage
transitions between stations (rather than stations being models of
their own).
You could have sub-types of CarWashing that would provide different
combinations of states (for the simple Wash'n'Wax to the full-on
hand-finished-chamois-wipe-down-with-under-body-jet-wash).

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



Re: [Rails] What Model Association?

2012-04-04 Thread Michael Pavling
On 4 April 2012 22:39, Mark 01 li...@ruby-forum.com wrote:
 I have the following two models and am not quite sure how they should be
 associated.

 - Car
 - CarWashStation

 At any given time, an instance of Car will be at (belong to?) one of a
 dozen car wash stations. What associations should I use (if any) between
 these models?


I would anticipate a CarWashing model, which has_one Car and one
CarWashStation, along with details about the time of the washing, what
soap was used, and which attendants conducted it (through an
AttendantsCarWashings join table), etc. A Car would then have many
CarWashings, and a named scope could give the current_car_washing.
Or something like that.

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



Re: [Rails] issues with model in ruby on rails

2012-04-03 Thread Michael Pavling
On 3 April 2012 09:12, amvis vgrkrish...@gmail.com wrote:
 class User  ActiveRecord::Base
   has_one  :system_admin
 end

 @user = User.find_by_user_name(user_name)
               if !@user.system_admins.nil?
                  puts 'am a sys_admin'

 The above code gives error

Since you've defined the association as a has_one, you should use it
in the singular:
  if !@user.system_admin.nil?

but !...nil? is a bit stinky; either use:
  if @user.system_admin
or
  unless @user.system_admins.nil?

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



Re: [Rails] Re: semi-OT: Is there an NNTP accessible version of this lis

2012-03-26 Thread Michael Pavling
On 26 March 2012 08:28, THUFIR H. li...@ruby-forum.com wrote:
 Or, you could just use a newsreader, which, presumably, is what the OP
 was after -- gmane.* groups.  It's an e-mail = nntp gateway, the web
 interface isn't really necessary at all.

??? Is this night of the living dead thread?
7 years old... do you think the OP is still watching for your answer?! ;-)

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



Re: [Rails] gsub

2012-03-23 Thread Michael Pavling
On 23 March 2012 10:36, Aaron Schmitz a.schmitz...@googlemail.com wrote:
 hi,

 im getting tired on this one.
 i want to replace all forwardslashes with backwardslashes.

 irb:
 r = C:/RAILS/
 r.gsub(/, \\) or r.gsub(/) {('\'} both give me:
 C:\\RAILS\\

 how can i use gsub to display only one \?

It's escaping it to show in the console, the string does have only one
backslash.

= \\.size
 1

;-)

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



Re: [Rails] gsub

2012-03-23 Thread Michael Pavling
On 23 March 2012 12:49, Aaron Schmitz a.schmitz...@googlemail.com wrote:
 next question! :D
 system(i_view32.exe C:\Rails\test.png /convert=C:\Rails\test.jpg)
 doesn't work.

What happens when you try:
  system(i_view32.exe C:\\Rails\\test.png /convert=C:\\Rails\\test.jpg)
?

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



Re: [Rails] gsub

2012-03-23 Thread Michael Pavling
On 23 March 2012 13:46, Aaron Schmitz a.schmitz...@googlemail.com wrote:
 is it a permission issue on win xp?
 the command is ok, i tested it in cmd.exe

Probably... I recommend a nice Linux install (even just a VM... ;-)

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



Re: [Rails] Modifying a gem, best way to deploy

2012-03-21 Thread Michael Pavling
On 21 March 2012 02:45,  c...@eq4.andreas-s.net wrote:
 For a project I used the gem 'event_calendar'. However, there were a
 couple things I had to manually change within the gem source to suit my
 needs.

 How would I go about to deploy this in production 'the rails way'?

A few choices:

* Vendorize it
* Package your own gem from the altered code
* Monkey-patch the gem in your lib folder

There's probably more options.

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



Re: [Rails] Re: Agile web development with rails 4th edition adding sizes to the product

2012-03-18 Thread Michael Pavling
On 18 March 2012 10:10, Shaban K. li...@ruby-forum.com wrote:
 What am I doing wrong?

You're not going through the whole tutorial, understanding it, and
then moving on to develop your own projects.

By all means twiddle with the example code, but always be able to get
back to how the book says it should be, or else you may have troubles
with the next exercise.

 My source code is attached.

You're missing an end from your products_controller, but that
wouldn't cause the error message you describe; it's more likely a
cut'n'paste error... but if you make one pasting error you might
make more.
Also, do you intend to have two Add to Cart forms posting to different routes?

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



Re: [Rails] The uniqueness for a field

2012-03-18 Thread Michael Pavling
On 18 March 2012 10:52, Soichi Ishida li...@ruby-forum.com wrote:
 Is there anyway to allow Videos to have the same 'value's, which however
 are distinct from each other among the values that a single Video
 possesses?

GIYF: 
http://stackoverflow.com/questions/5494660/how-to-validate-uniqueness-in-rails-3-model-if-i-want-to-check-if-there-is-a-2-f

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



Re: [Rails] distinctively difficult to do what I want

2012-03-16 Thread Michael Pavling
On 16 March 2012 16:59, Colin Law clan...@googlemail.com wrote:
 On 16 March 2012 15:41, bingo bob li...@ruby-forum.com wrote:
 I have a database with a lot of Name objects in it, some have the same
 given name - ok fairly normal.

 I simply wish to return all the Names with a unique given name.
 *important* I an array of objects returned not just the given names so I
 can access all the attributes of the name when they're returned, i.e. in
 my view I need the full object to get at the user and gender etc.

 But how will the
 code know which of the records with given == fred that you want?
 The other attributes may be different between the fred records.

+1
You might be satisfied with .group_by(:given) on a collection of
all the Name objects, which would give you a list of unique names,
while still giving access to all the individual records. But this
could be slow if you have a large collection.

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



Re: [Rails] NoMethodError

2012-03-12 Thread Michael Pavling
On 9 March 2012 19:52, AndyLikesRuby usbd...@gmail.com wrote:
 I am getting this error message when I try to hit a certain URL:

 http://localhost:3000/captionfiles

 NoMethodError in CaptionfilesController#index
 undefined method `all' for Captionfile:Class
 app/controllers/captionfiles_controller.rb:5:in `index'

    @captionfiles = Captionfile.all

 class Captionfile  ActiveRecord::Base

There's nothing, at first glance, wrong with your code. So can you
just confirm which version of Rails you have installed. Older (very
old!) versions didn't have .all, you had to use .find(:all). But
if that's your problem, you must be on Rails 1.x, and that won't be
the last of your problems...

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



Re: [Rails] [Rails Guides] Getting Started 7.4 - Array Output Problem

2012-03-08 Thread Michael Pavling
On 7 March 2012 12:04, NoobyOnRails satchillana...@web.de wrote:
 When I want to show the comment I get the following output under my
 comment:

 [#Comment id: 1, commenter: Tester, body: This is a test comment,
 post_id: 1, created_at: 2012-03-07 11:48:02, updated_at: 2012-03-07
 11:48:02]

You're possibly doing this:

%= @my_object.comments.each do |comment| %
 # and then code to output the comment
% end %

rather than:

% @my_object.comments.each do |comment| %
 # and then code to output the comment
% end %

The equals sign before the iterator will output to the browser the
result of the iterator (which will be the collection that's iterated).
You can see the Comment displayed has square brackets around it, which
indicate it's a single element array - so probably a collection that's
being rendered by mistake.

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



Re: [Rails] Include Advanced

2012-03-08 Thread Michael Pavling
On 8 March 2012 22:49, Rogelio A. RogeX li...@ruby-forum.com wrote:
 Hi, As I can do Include with parameters??

 Example

 Modelo.find(:all,:include = [otroModelo(param,param)])

Modelo.find(:all,:include = :otro_modelo, :conditions =
[otro_modelos.param1 = ? and otro_modelos.param2 = ?, param, param])

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



Re: [Rails] unable to interchange ruby versions using RVM

2012-03-06 Thread Michael Pavling
On 6 March 2012 12:31, honey ruby emailtohoneyr...@gmail.com wrote:
 hey guys i got the solutions

Fancy sharing it for posterity so that anyone who gets the same error
in future can search for it before posting?

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



  1   2   3   4   5   6   7   8   9   10   >