[Rails] How to save xml values to mysql database

2013-06-25 Thread keerthi priya
Hi All, 

  I have a xml and I have to save those values into my mysql 
database using ruby1.87. How can I do it. Kindly guide me how can I get 
values and save them.




Thanks in advance

Cheers,
Kp 

-- 
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/0712c533-ae57-4893-8d46-ed28bc1812c1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Singapore based CTO/ Co Founder needed

2013-06-25 Thread Goders

,
Hello Rubysts

We are an online global marketplace start-up founded by well experience 
ecommerce and retail expert INSEAD graduate. 
We are looking for a CTO to join our team and lead the technological 
development. 

What you need for this position:

- BA/BS degree – CS/EE/Engineering degree preferred
- 4+ years of web development, mobile, social, and E-Commerce experience
- Experience managing development projects with tight schedules
- e-Commerce and marketplaces industry experience strongly preferred
- Experience creating web applications that scale for hundreds of thousands 
of users or more, ideally with MVC frameworks such as Python, Django, Ruby 
on Rails 
- Experience implementing web interfaces using XHTML, CSS, Javascript, and 
AJAX
- Experience in recommendation engines and algorithms
- Interest in working in an early stage fast-paced startup environment

What you'll be doing:

- Provide technical vision for product and infrastructure features
- Work with CEO/Product Management to enhance the user experience
- Manage external contractors and on a later stage manage an internal 
development team
- Manage the development process and release schedule
- Define and document development methods, and share best practices
- Review and recommend improvements to product architecture
- Company-wide IT leadership
- Conduct code reviews and provide technical recommendations

What's in it for you:

-  Major Equity in company
- Chance to get in on the ground floor and Co-Found an exciting fast-pace 
Start-up! 

-- 
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/0a4c0ca4-28ed-48f7-884b-55d02865b9e5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Tutorials for beginner

2013-06-25 Thread r@ilsman
I am learning ROR
Please suggest good rails sample applications.
Thanks.

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/9d28d108-b7ee-4475-bea0-ecb6a6ba6f38%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] How to save xml values to mysql database

2013-06-25 Thread Tamara Temple
keerthi priya emailtokeerthipr...@gmail.com wrote:
 I have a xml and I have to save those values into my mysql database using 
 ruby1.87. How can I do it. Kindly guide me how can I get
 values and save them.

This really is not anywhere near enough of a description to determine
what you want. Are you unsure how to read and parse the XML? Are you
unsure how to create a record and save it? I'm going to go way out on a
limb here and assume you are using Rails, but which ORM? ActiveRecord?
And which version of Rails are you running with Ruby 1.8.7? Rails 2.x?
Can you google? Have you read documentation? What have you tried so far?

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+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/51c96031.2576320a.2c47.700c%40mx.google.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] [HELP] Couldn't find Search with id= from controller

2013-06-25 Thread Tamara Temple
cornelius wilson li...@ruby-forum.com wrote:
 I have been working on the search form for my app. The advanced search
 works fine, however I am unable to get the regular search form to work.
 It should be able to search the entire user database, and I should be
 able to string keywords together. For example if I search the term no
 kids it should return the results for everyone who has no kids listed
 on their profile. Then if I want to be more advance I can search no
 kids, asian and this would of course pull up users with Asian ethnicity
 that has no kids.
 
 When I do this I get the following error: Couldn't find Search with
 id=kids. It points to the searches controller for the following line:
 
 def index
 @search = Search.find(params[:search])
 
 Also a quick note I am following the railscast 111 for this.
 
 Attachments:
 http://www.ruby-forum.com/attachment/8535/searches_controller.rb
 http://www.ruby-forum.com/attachment/8536/user.rb
 http://www.ruby-forum.com/attachment/8537/search.rb

What's in the searches table? How are you populating it to do a
Search.find? I'm a wee bit unclear why there's a Search model at all,
really...

-- 
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/51c963ec.e6a4320a.3064.721d%40mx.google.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: How to create a two dimensional table

2013-06-25 Thread Saro V.
If the content of Col1 and Col2 is dynamic?

I have this

MODEL
-
class Forecast  ActiveRecord::Base

  belongs_to :employee
  belongs_to :prefshift

  attr_accessible :employee_id, :giorno, :prefshift_id

end
--

and i want to have this present on web

VIEW
---
 01/07/2013 | 02/07/2013 | 03/07/2013 | 
prefshift1   employee3  employee1
prefshit2employee8  employee5
prefshift3  employee6
prefshift4   employee3  employee1   employee5




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

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




[Rails] Correct use of before_validation

2013-06-25 Thread Joel Pearson
I'm using Rails 3.2.13 with Ruby 2.0.0

I have a field in a form called hours which normally passes a
numerical value.

However, my users also want the option to pass time values, like
01:15, 00:25, :05, etc.

I've tried to allow for this sort of thing with the below code:

__
  validates :hours, :presence = true, :numericality = { :greater_than
= 0, :less_than = 12 }

  before_validation do
STDOUT  'Test'
self.hours = hours.scan( /(\d*):(\d*)/ ).map { |hrs, mins| hrs.to_f
+ ( mins.to_f / 60.0 ) }.first.round(4) if hours  hours =~ /:/
  end
__

The problem I'm getting is that the validation doesn't appear to fire at
all.

When I input :05, for example.

The form states that Hours is not a number.
I don't see Test in the server console.

The code converting from a time string into a float appears to work in
IRB.

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

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




[Rails] Re: Correct use of before_validation

2013-06-25 Thread Joel Pearson
I've managed to get the event to fire now, but what I get from STDOUT is 
0.0
So I guess that means I'm not receiving a string from input.


  before_validation :convert_hours

  protected

  def convert_hours
STDOUT  hours
if hours  hours =~ /:/
  hrs, mins = hours.scan( /(\d*):(\d*)/ ).first
  self.hours = ( hrs.to_f + ( mins.to_f / 60.0 ) ).round(4)
end
  end



However, the validation that triggers:


validates :hours, :presence = true, :numericality = { :greater_than = 
0, :less_than = 12 }


States that Hours is not a number.

So where is this 0.0 coming from? Is it even possible to get this value 
as a string if it's a Decimal in the database?

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

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To 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/a1eab4e283ac003a4c3190f709a70bfa%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: Correct use of before_validation

2013-06-25 Thread Joel Pearson
Catching that 0.0 value was the right direction to look in:

  def convert_hours
if hours_before_type_cast  hours_before_type_cast =~ /:/
  hrs, mins = hours_before_type_cast.scan( /(\d*):(\d*)/ ).first
  self.hours = BigDecimal( ( hrs.to_f + ( mins.to_f / 60.0 ) ), 4 )
end
  end

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

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+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/d46fefdd80f3d78759b87c92398c8aef%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: [HELP] Couldn't find Search with id= from controller

2013-06-25 Thread cornelius wilson
I have it as a model to save all the searches to database. Originally I 
thought it would be good to have information on what users are searching 
for on a dating app, though I have back away from this in recent weeks. 
I just haven't removed it as I don't want to break the app.

Searches table has gender, age, children, religion, ethnicity, created 
at, updated at.

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

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




[Rails] Select box 4 Tables

2013-06-25 Thread Marco Gergen
Hello and sry for my english.

I have no idea what can i do with my problem. I hope everybody can help
me.

I have 4 Tables.

Table A
a_id

Table B
b_id
a_id
c_id

Table C
c_id
d_id

Table D
d_id

whit the table-association A 1--n B n--1 C n--1 D

In my View i have a f.select for the association A-B-C.

The Problem is that i have in the selectbox double-data and i need one
more selectbox for the association C--D in the same View. Like this
http://webkrauts.de/wp-content/uploads/2007/05/forms-select-ff-01.png

I have search for the answer but i can find a solution for my problem.

Thank you very very very much.

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

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To 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/846f2d72ba41a01cccdb550bdb469feb%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: Ruby On Rails integrate with Object C

2013-06-25 Thread Scott Ribe
On Jun 24, 2013, at 11:50 AM, haxuan lac wrote:

 I don't konw how to use this method in ROR

You can't (without writing a gem, which would only run on iOS/OSX), you use 
them from an Objective-C app. The problem is that your question was extremely 
vague, some kind person tried to guess what your question really was and answer 
it, and apparently guessed wrong.

Ask about what you specifically need to do.

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




-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To 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/4C54B6E0-4D23-4F71-9A0B-35030BE671E5%40elevated-dev.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] How to restart AR transaction?

2013-06-25 Thread Scott Ribe
Look at the actual SQL in the logs.

On Jun 3, 2013, at 9:01 PM, Ken Ip wrote:

 Thanks for the reply, Scott. Can you show me how? I've tried per this but it 
 still doesn't work.
 
 
 self.transaction do
   bar = create(params) rescue nil
   raise ActiveRecord::Rollback unless bar
 end
 unless bar
   self.transaction do
 bar = find_or_initialize_by(foo: foo)
 bar.update(params)
   end
 end
 
 
 On Monday, June 3, 2013 11:57:21 AM UTC-4, Scott Ribe wrote:
 On Jun 3, 2013, at 9:27 AM, Ken Ip wrote: 
 
  and PG would still complain about it with PG::Error: ERROR: current 
  transaction is aborted, commands ignored until end of transaction block. 
  So my question is whether there is a proper way of restarting the 
  transaction? Thanks! 
 
 rollback 
 
 -- 
 Scott Ribe 
 scott...@elevated-dev.com 
 http://www.elevated-dev.com/ 
 (303) 722-0567 voice 
 
 
 
 
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 Ruby on Rails: Talk group.
 To 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/df6adad0-6740-400a-8771-f034d54452fe%40googlegroups.com?hl=en-US.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  


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




-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To 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/E01BEA3F-7C43-4A31-B40E-D1E5CD894D39%40elevated-dev.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] attr :location_string

2013-06-25 Thread Christopher Frost
Hi,

I have come across attr :location_string inside a class definition in
Rails application.

class Web  class Params
  attr :location_string

  def 
  end

  
end


I know how attr_accessor, attr_reader or attr_writer works.
But I don't have any idea on attr in Rails.

Can you kindly explain what it does?

Thanks,
Christopher

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

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




[Rails] cap deploy:setup fails

2013-06-25 Thread John Merlino
I run cap deploy:setup

And towards the end, I see the following issues:

** [out :: xxx.xx.xx.132] Unrecognized command line flag: 
'--autolibs=read-only' ( see: 'rvm usage' )
 ** [out :: xxx.xx.xx.134] Already installed ruby-1.9.3-p0.
 ** [out :: xxx.xx.xx.134] To reinstall use:
 ** [out :: xxx.xx.xx.134] 
 ** [out :: xxx.xx.xx.134] rvm reinstall ruby-1.9.3-p0
 ** [out :: xxx.xx.xx.134] 
 ** [out :: xxx.xx.xx.132] Ruby ruby-1.9.3-p0 is not installed.
 ** [out :: xxx.xx.xx.134] gemset created spree_ecommerce = 
/usr/local/rvm/gems/ruby-1.9.3-p0@spree_ecommerce
command finished in 931ms
failed: bash -c '__LAST_STATUS=0; export 
CURL_HOME=\${TMPDIR:-${HOME}}/.rvm-curl-config.$$\; mkdir ${CURL_HOME}/; 
{ [[ -r ${HOME}/.curlrc ]]  cat ${HOME}/.curlrc; echo \silent\; echo 
\show-error\; }  $CURL_HOME/.curlrc; sudo -p '\\''sudo password: '\\'' 
sg rvm -c \/usr/local/rvm/bin/rvm --autolibs=read-only install 
ruby-1.9.3-p0 -j $(cat /proc/cpuinfo 2/dev/null | (grep vendor_id || echo 
'\\''vendor_id : Other'\\'';) | wc -l) \; sudo -p '\\''sudo password: 
'\\'' sg rvm -c \/usr/local/rvm/bin/rvm ruby-1.9.3-p0 do rvm gemset create 
spree_ecommerce\ || __LAST_STATUS=$?; rm -rf $CURL_HOME; exit 
${__LAST_STATUS}' on xxx.xx.xx.132

Note that I have another rails application, that deploys fine, whose deploy 
configuration is very very similar. Here's the deploy.rb:

require 'capistrano/ext/multistage'
require rvm/capistrano
require 'bundler/capistrano'

after deploy:update_code, deploy:symlink_shared_configs
load 'deploy/assets'

set :application, SpreeSite

set :stages, [staging, production]
set :default_stage, production

set :scm, git
set :repository,  g...@github.com:MyAccount/SpreeSite.git
set :branch, master
default_run_options[:pty] = true

role :web, xxx.xx.xx.134  # Your HTTP server, 
Apache/etc
role :app, xxx.xx.xx.134  # This may be the 
same as your `Web` server
role :db,  xxx.xx.xx.132, :primary = true# This is where 
Rails migrations will run

set :deploy_to, ~/public_html/mysite.com/

set :user, ubuntuuser
set :use_sudo, false

set :deploy_via, :remote_cache

set :rvm_ruby_string, 'ruby-1.9.3-p0@spree_ecommerce' #this failed on 
remote server when using ruby-1.9.3@spree_ecommerce !! 
set :rvm_autolibs_flag, read-only

set :rvm_type, :system
set :rvm_install_with_sudo, true

before 'deploy:setup', 'rvm:install_rvm'   # install RVM
before 'deploy:setup', 'rvm:install_ruby'  # install Ruby and create 
gemset, OR:
before 'deploy:setup', 'rvm:create_gemset' # only create gemset
 
# If you are using Passenger mod_rails uncomment this:
 namespace :deploy do
   desc Symlink configuration files
   task :symlink_shared_configs, :roles = [:db,:app] do
 run ln -nfs #{shared_path}/config/database.yml 
#{release_path}/config/database.yml
   end
 
   task :start do ; end
   task :stop do ; end
   task :restart, :roles = :app, :except = { :no_release = true } do
 run #{try_sudo} touch 
#{File.join(current_path,'tmp','restart.txt')}
   end
 end

#deploy/production.rb:

set :deploy_to, /home/ubuntuuser/public_html/mysite.com/
set :rails_env, 'production'

-- 
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/5c19417a-45e3-4d0a-8dff-980ca22d513d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: How to save xml values to mysql database

2013-06-25 Thread Matt Jones


On Tuesday, 25 June 2013 00:01:54 UTC-7, keerthi priya wrote:

 Hi All, 

   I have a xml and I have to save those values into my mysql 
 database using ruby1.87. How can I do it. Kindly guide me how can I get 
 values and save them.


Use Ruby. :)

But seriously, you're going to have to provide a great deal more detail for 
anybody to help you on this one. What are you trying to get out the XML? 
What's the database schema you're putting the values *into*?

Most importantly, what have you tried so far?

--Matt Jones 

-- 
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/9dd7f2f5-031e-4c5d-b91c-3b493677dcd4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Tutorials for beginner

2013-06-25 Thread Colin Law
On 25 June 2013 06:50, r@ilsman rabindranath.prit...@heymath.com wrote:
 I am learning ROR
 Please suggest good rails sample applications.

Work right through a good tutorial such as railstutorial.org, which is
free to use online, and also the Rails Guides.

Colin

 Thanks.

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Talk group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to rubyonrails-talk+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/rubyonrails-talk/9d28d108-b7ee-4475-bea0-ecb6a6ba6f38%40googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.



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




Re: [Rails] Re: How to create a two dimensional table

2013-06-25 Thread Colin Law
On 25 June 2013 10:48, Saro V. li...@ruby-forum.com wrote:
 If the content of Col1 and Col2 is dynamic?

Did you realise that you have replied to a thread from 2009?  I hope
the OP has not been waiting all this time for an answer.

Colin

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




Re: [Rails] [HELP] Couldn't find Search with id= from controller

2013-06-25 Thread Colin Law
On 24 June 2013 20:05, cornelius wilson li...@ruby-forum.com wrote:
 I have been working on the search form for my app. The advanced search
 works fine, however I am unable to get the regular search form to work.
 It should be able to search the entire user database, and I should be
 able to string keywords together. For example if I search the term no
 kids it should return the results for everyone who has no kids listed
 on their profile. Then if I want to be more advance I can search no
 kids, asian and this would of course pull up users with Asian ethnicity
 that has no kids.

 When I do this I get the following error: Couldn't find Search with
 id=kids. It points to the searches controller for the following line:

 def index
 @search = Search.find(params[:search])

find expects a numeric id value, presumable params[:search] is set to
kids rather than an id.

Colin

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




[Rails] creating an account with a username in devise

2013-06-25 Thread monte olvera
Hello, all.  I have followed these links and have enabled a (current)
user to login with a username:

http://railscasts.com/episodes/209-introducing-devise
http://railscasts.com/episodes/210-customizing-devise
https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign-in-using-their-username-or-email-address

I want to allow a user to sign up with a username but am getting these
errors and don't know how to proceed.  Notice the 'Email can't be blank'
error, even though I'm not wanting to accept an email for
authentication.  It also doesn't recognize that I entered a password or
that they matched (even though they did):

Sign up
3 errors prohibited this user from being saved:
Email can't be blank
Password can't be blank
Password confirmation doesn't match Password


Please see attached devise view new.html.erb and devise model user.rb

Please let me know if you require any further information.  Any help
would be greatly appreciated.  Thanks.

Attachments:
http://www.ruby-forum.com/attachment/8539/new.html.erb
http://www.ruby-forum.com/attachment/8540/user.rb


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

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To 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/f85bd747954322568fa15d10171e77f4%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] creating an account with a username in devise

2013-06-25 Thread Dave Aronson
On Tue, Jun 25, 2013 at 5:06 PM, monte olvera li...@ruby-forum.com wrote:

 I want to allow a user to sign up with a username but am getting these
 errors and don't know how to proceed.  Notice the 'Email can't be blank'
 error, even though I'm not wanting to accept an email for
 authentication.

Did you remember to set config.authentication_keys = [:username] in
the initializer?  Show us at least the non-commented-out lines.

 It also doesn't recognize that I entered a password or
 that they matched (even though they did):

That sounds like you may be pulling out the wrong part of the params.
Can you show us the controller action and logged params?  Or are you
just using the default Devise controllers?

-Dave

-- 
Dave Aronson, the T. Rex of Codosaurus LLC,
secret-cleared freelance software developer
taking contracts in or near NoVa or remote.
See information at http://www.Codosaur.us/.

-- 
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/CAHxKQijP%2BA%3DwLTPmET_xx4cfVAChBbsiBujs8mjMunXEaX%3D-mg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: creating an account with a username in devise

2013-06-25 Thread monte olvera
 Did you remember to set config.authentication_keys = [:username] in
 the initializer?  Show us at least the non-commented-out lines.
$ grep -v \# config/initializers/devise.rb |grep .
Devise.setup do |config|
  config.mailer_sender = password_re...@gloryhouseofprayer.com
  require 'devise/orm/active_record'
  config.case_insensitive_keys = [ :username ]
  config.strip_whitespace_keys = [ :username ]
  config.stretches = Rails.env.test? ? 1 : 10
  config.use_salt_as_remember_token = true
  config.timeout_in = 30.minutes
  config.reset_password_within = 2.hours
  config.sign_out_via = :get
  config.authentication_keys = [ :username ]
  config.reset_password_keys = [ :username ]
  config.confirmation_keys = [ :username ]
end


 That sounds like you may be pulling out the wrong part of the params.
 Can you show us the controller action and logged params?  Or are you
 just using the default Devise controllers?

I apologize if I'm not following you, because I'm new to Ruby on Rails, 
but Devise didn't install any Controller, nor did it add anything to the 
default app/controller/application_controller.rb.  So, I assume I'm 
using the default.  However I did add an entry to my application's 
controller so I could authenticate before going to any page:

$ cat app/controllers/my_app_controller.rb
class MyAppController  ApplicationController
  before_filter :authenticate_user!
...

When I was looking through the logs (to respond to your logged params 
question I found this error:
Started POST /users for 127.0.0.1 at 2013-06-25 19:29:41 -0400
Processing by Devise::RegistrationsController#create as HTML
  Parameters: {utf8=✓, 
authenticity_token=tltbt2w5FkZQbkbLqYaZIPiqk3J7VsdQIvKWFDCYLAs=, 
user={firstname=bob, lastname=smith, 
password=[FILTERED], password_confirmation=[FILTERED]}, 
commit=Sign up}
WARNING: Can't mass-assign protected attributes for User: password

So, I googled it and saw references to removing the attr_protected 
:password from the model (user.rb).

I did that and now only get the Email can't be blank error when trying 
to sign up a user.

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

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




[Rails] Re: creating an account with a username in devise

2013-06-25 Thread monte olvera
Here are the logs I get from rack when submitting the 'sign up' form:

Started POST /users for 127.0.0.1 at 2013-06-25 19:50:18 -0400
Processing by Devise::RegistrationsController#create as HTML
  Parameters: {utf8=✓, 
authenticity_token=tltbt2w5FkZQbkbLqYaZIPiqk3J7VsdQIvKWFDCYLAs=, 
user={firstname=bob, lastname=smith, 
password=[FILTERED], password_confirmation=[FILTERED]}, 
commit=Sign up}
   (0.1ms)  begin transaction
   (0.1ms)  rollback transaction
  Rendered devise/shared/_links.erb (0.3ms)
  Rendered devise/registrations/new.html.erb within layouts/application 
(3.6ms)
Completed 200 OK in 97ms (Views: 10.8ms | ActiveRecord: 0.2ms)


Started GET /assets/application.css?body=1 for 127.0.0.1 at 2013-06-25 
19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true


Started GET /assets/bootstrap_and_overrides.css?body=1 for 127.0.0.1 
at 2013-06-25 19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true


Started GET /assets/jquery.js?body=1 for 127.0.0.1 at 2013-06-25 
19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true


Started GET /assets/jquery_ujs.js?body=1 for 127.0.0.1 at 2013-06-25 
19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true


Started GET /assets/twitter/bootstrap/bootstrap-transition.js?body=1 
for 127.0.0.1 at 2013-06-25 19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true


Started GET /assets/twitter/bootstrap/bootstrap-alert.js?body=1 for 
127.0.0.1 at 2013-06-25 19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true


Started GET /assets/twitter/bootstrap/bootstrap-modal.js?body=1 for 
127.0.0.1 at 2013-06-25 19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true


Started GET /assets/twitter/bootstrap/bootstrap-dropdown.js?body=1 for 
127.0.0.1 at 2013-06-25 19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true


Started GET /assets/twitter/bootstrap/bootstrap-scrollspy.js?body=1 
for 127.0.0.1 at 2013-06-25 19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true


Started GET /assets/twitter/bootstrap/bootstrap-tab.js?body=1 for 
127.0.0.1 at 2013-06-25 19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true


Started GET /assets/twitter/bootstrap/bootstrap-tooltip.js?body=1 for 
127.0.0.1 at 2013-06-25 19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true


Started GET /assets/twitter/bootstrap/bootstrap-popover.js?body=1 for 
127.0.0.1 at 2013-06-25 19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true


Started GET /assets/twitter/bootstrap/bootstrap-button.js?body=1 for 
127.0.0.1 at 2013-06-25 19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true


Started GET /assets/twitter/bootstrap/bootstrap-carousel.js?body=1 for 
127.0.0.1 at 2013-06-25 19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true


Started GET /assets/twitter/bootstrap/bootstrap-collapse.js?body=1 for 
127.0.0.1 at 2013-06-25 19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true


Started GET /assets/twitter/bootstrap/bootstrap-typeahead.js?body=1 
for 127.0.0.1 at 2013-06-25 19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true


Started GET /assets/twitter/bootstrap/bootstrap-affix.js?body=1 for 
127.0.0.1 at 2013-06-25 19:50:18 -0400
[2013-06-25 19:50:18] WARN  Could not determine content-length of 
response body. Set content-length of the response or set 
Response#chunked = true



[Rails] SAVON - Call

2013-06-25 Thread Otavio Nestares
**

I have this method on a web service I'm consuming, using SAVON 3 on Rails 3
and Ruby 1.9.7 web app

soapenv:Envelope
xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/;
xmlns:tem=http://tempuri.org/;
xmlns:gpa=http://schemas.datacontract.org/2004/07/Gpa.Comercio.Servicos.Contracts.DTO;
   soapenv:Header/
   soapenv:Body
  tem:CalcularCarrinho
 !--Optional:--
 tem:carrinho
!--Optional:--
gpa:CEPparameter here/gpa:CEP
!--Optional:--
gpa:CNPJparameter here/gpa:CNPJ
!--Optional:--
gpa:IdCampanha parameter here /gpa:IdCampanha
!--Optional:--
gpa:Produtos
   !--Zero or more repetitions:--
   gpa:DadosListaProdutoCarrinhoDTO
  !--Optional:--
  gpa:Codigo parameter here /gpa:Codigo
  !--Optional:--
  gpa:Quantidadeparameter here/gpa:Quantidade
   /gpa:DadosListaProdutoCarrinhoDTO
/gpa:Produtos
 /tem:carrinho
  /tem:CalcularCarrinho
   /soapenv:Body/soapenv:Envelope

How should I make a call to this method, considering that the Produtos
parameter is an array? I tried:

client.call(:calcular_carrinho){message(id_campanha: 2543, cnpj:
'93.528.261/0001-60', cep: '04080013', produtos: ['379457', 1])}

P.S: I made tests with soapUI and the service is working...


Best!

-- 
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/CABN%3DCd6vRiw%2BDdmd8kfvYd_W3_xsNpDmre45Svo2Bc135%3DOv7A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: creating an account with a username in devise

2013-06-25 Thread Dave Aronson
On Tue, Jun 25, 2013 at 7:48 PM, monte olvera li...@ruby-forum.com wrote:

 Did you remember to set config.authentication_keys = [:username] in
 the initializer?  Show us at least the non-commented-out lines.

 $ grep -v \# config/initializers/devise.rb |grep .

Ah, we're obviously not dealing with a total programming-newbie here!  :-)

   config.case_insensitive_keys = [ :username ]
   config.strip_whitespace_keys = [ :username ]
...
   config.authentication_keys = [ :username ]
   config.reset_password_keys = [ :username ]
   config.confirmation_keys = [ :username ]

Okay, so far so good.  Just to be sure, I compared it with one of my
apps that uses username to log in, and the only other mention of
username I had was config.unlock_keys (which you might not be using at
all).

 That sounds like you may be pulling out the wrong part of the params.
 Can you show us the controller action and logged params?  Or are you
 just using the default Devise controllers?

 I apologize if I'm not following you, because I'm new to Ruby on Rails,
 but Devise didn't install any Controller,

Actually, it does, just not placed in with your own controllers.  In
its own directory, it has controllers and views and so on.  Gems
provide Rails additional places to find such things.  Some, such as
Devise, also let you install stuff into your app's code dirs so that
you can mess with them.  (I'm guessing you did that with its views, in
order to make it ask for first and last name instead of email.)  Some
don't, and are meant to run strictly out of their own dirs (modulo the
configuration initializer).

 I assume I'm using the default.

I'd agree.

  However I did add an entry to my application's
 controller so I could authenticate before going to any page:

 $ cat app/controllers/my_app_controller.rb
 class MyAppController  ApplicationController
   before_filter :authenticate_user!

That should be fine.

 When I was looking through the logs (to respond to your logged params
 question I found this error:

The rest of it looks good, confirming you're sending the right stuff
to the right place.

 WARNING: Can't mass-assign protected attributes for User: password

 So, I googled it and saw references to removing the attr_protected
 :password from the model (user.rb).

Yes, that's fairly important to understand.  Another idea, though, is
to get a bit ahead of the curve, and use Rails 4 with its strong
parameters.  4 was just released today, so it's now officially stable
so you can build with it confidently.  Also, if you're trying to get
actual paid work in it, it's new enough that the competition will have
some struggles too, which evens the playing field a bit against
grizzled veterans like me.  Oh, wait, never mind, stick with Rails 3,
better yet go check out Rails 2, pay no attention to the release no
longer behind the curtain ;-)

 I did that and now only get the Email can't be blank
 error when trying to sign up a user.

Ah, good progress.

Maybe there's still a validation looking for email in your User class?
 Can you post that?

You could also go on a search and destroy mission: find all mentions
of email in your app and examine them to see if they could be the
cause.  (Do you know about the ack utility?)

Come to think of it, there's a much simpler possibility; it may sound
stupid, but we've all done it.  Maybe you didn't restart your Rails
server after modifying Devise.  You need to do that to make it reread
the initializers, such as the one that tells Devise what fields to use
as keys.

-Dave

-- 
Dave Aronson, the T. Rex of Codosaurus LLC,
secret-cleared freelance software developer
taking contracts in or near NoVa or remote.
See information at http://www.Codosaur.us/.

-- 
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/CAHxKQigLxW0pgn22sYm6ar4qgC3O7f1Kp0sdFjrjx2JLxbug7g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: Re: creating an account with a username in devise

2013-06-25 Thread monte olvera
first of all, thanks man for helping me, I really appreciate it!

 Ah, we're obviously not dealing with a total programming-newbie here!
 :-)

:)  I said I was new to Ruby, not to programming.  Started with Qbasic 
on my commodore back in 1995 when I was 10. I know Assembly, C/C++, 
Python, Shell, PHP.  But I digress

 Actually, it does, just not placed in with your own controllers.  In
 its own directory, it has controllers and views and so on.  Gems
 provide Rails additional places to find such things.  Some, such as
 Devise, also let you install stuff into your app's code dirs so that
 you can mess with them.

Here's what I ran to install devise:
rails generate devise:install
rails generate devise user
rails generate devise:views

 (I'm guessing you did that with its views, in
 order to make it ask for first and last name instead of email.)

Nope, I edited that myself because I couldn't find anything anywhere.

 parameters.  4 was just released today

I am using rails 4:
$ rails -v
Rails 4.0.0.rc2


 Also, if you're trying to get actual paid work in it

Ha!  I better not be, my resume would read:  I googled stuff!

Actually I want to get this (personal) project done and figured I'd go 
back and learn why I did what I did and why it worked later.  This goes 
against everything in me but I simply don't have the time (right now) to 
dedicate a month to fully learning ruby on rails before getting this 
project done.

 Maybe there's still a validation looking for email in your User class?
  Can you post that?

$ grep -v \# app/models/user.rb |grep .
class User  ActiveRecord::Base
  devise :database_authenticatable, :registerable, :recoverable, 
:rememberable, :trackable, :validatable, :authentication_keys = 
[:username]
  validates_presence_of :firstname, :lastname, :unique = true
  after_validation :createUsername
  attr_accessible :username, :password, :password_confirmation, 
:remember_me, :firstname, :lastname
  def createUsername
firstnamePart=self.firstname[0,1].downcase
lastnamePart=self.lastname[0,5].downcase
username=lastnamePart + firstnamePart
count=0
while username.length != 7
  username=username + count.to_s
  count +=1
end
self.username=username
  end
  def self.find_first_by_auth_conditions(warden_conditions)
  conditions = warden_conditions.dup
  if login = conditions.delete(:login)
where(conditions).where([lower(username) = :value OR 
lower(email) = :value, { :value = login.downcase }]).first
  else
where(conditions).first
  end
end
end

 You could also go on a search and destroy mission: find all mentions
 of email in your app and examine them to see if they could be the
 cause.

$ grep -ri email *|egrep -v #|log
app/views/devise/mailer/unlock_instructions.html.erb:pHello %= 
@resource.email %!/p
app/views/devise/mailer/confirmation_instructions.html.erb:pWelcome 
%= @resource.email %!/p
app/views/devise/mailer/reset_password_instructions.html.erb:pHello 
%= @resource.email %!/p
app/views/devise/mailer/reset_password_instructions.html.erb:pIf you 
didn't request this, please ignore this email./p
config/locales/devise.en.yml:  send_instructions: 'You will receive 
an email with instructions about how to reset your password in a few 
minutes.'
config/locales/devise.en.yml:  send_instructions: 'You will receive 
an email with instructions about how to confirm your account in a few 
minutes.'
config/locales/devise.en.yml:  send_paranoid_instructions: 'If your 
e-mail exists on our database, you will receive an email with 
instructions about how to confirm your account in a few minutes.'
config/locales/devise.en.yml:  send_instructions: 'You will receive 
an email with instructions about how to unlock your account in a few 
minutes.'
config/locales/devise.en.yml:  send_paranoid_instructions: 'If your 
account exists, you will receive an email with instructions about how to 
unlock it in a few minutes.'
Binary file db/development.sqlite3 matches
db/schema.rb:t.string   email, 
default: , null: false
db/schema.rb:  add_index users, [email], name: 
index_users_on_email, unique: true
Binary file 
tmp/cache/assets/development/sprockets/d585a06e2ee6203ccb04c8b84150d14d 
matches
Binary file 
tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 
matches
Binary file 
tmp/cache/assets/development/sprockets/8c2b061e379a23e7c4d207adcf992462 
matches
Binary file 
tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 
matches
Binary file 
tmp/cache/assets/development/sprockets/b7fc7a50cc3464d16f378714639f14e2 
matches

 (Do you know about the ack utility?)
a rails utility?  Nope, never heard of an 'ack' utility.


 Maybe you didn't restart your Rails server after modifying Devise.
I've only done that 500 times.  Really, after every single change I made 
I restarted rack, just in case.

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

-- 
You received this message because you are 

[Rails] Re: creating an account with a username in devise

2013-06-25 Thread monte olvera
that 'email' reference search looked lousy posting it directly, so here
it is in an attached file.

Attachments:
http://www.ruby-forum.com/attachment/8541/rails_app_email_references


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

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




[Rails] Re: Relational DB - Related and not Related

2013-06-25 Thread Cameron Gilroy
Here is an update, I have it working as only a group or as only a non-group 
user. I have below the create controller and was wondering what would be 
the best way to allow associations and non-associated records. Thanks

  def create
if Group.nil?
  @group = Group.find(params[:group_id])
  @user = @group.users.create(params[:user])
else
  @user = User.new
  @user.ip_address = request.remote_ip
  @user.ua_string = request.user_agent
  @user = User.new(params[:user])
end

respond_to do |format|
  if @user.save  @user.group_id == nil
format.html { redirect_to /, notice: 'Thank you for registering!' 
}
  elsif @user.save  @user.group_id != 
format.html { redirect_to group_path(@group.token), notice: 'Thank 
you for registering!' }
  else
format.html { render action: new }
format.json { render json: @user.errors, status: 
:unprocessable_entity }
  end
end
  end

On Monday, June 24, 2013 10:54:14 PM UTC+10, Cameron Gilroy wrote:

 Hi

 I'm working on a project that has users and groups, users can be members 
 of a group *or* they can just be a user - what's going to be the best way 
 to deal with this?
 I understand the normal has_many relationship just not sure how to do this 
 one. Will try to post some code snippets tomorrow.

 Thanks, Cameron


-- 
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/db8099f1-e254-428d-9462-01174f13bda6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Capistrano Git SSH problem

2013-06-25 Thread news.anand11
Hi, I am using Capistrano for deployment. And bitnami in my ec2 linux
instance. I have configured Capistrano for deployment and deploy:check says
all is fine. But I am facing problem while doing deploy. Here is the full
stack

$ cap deploy:check
triggering load callbacks
  * 2013-06-26 08:38:11 executing `staging'
triggering start callbacks for `deploy:check'
  * 2013-06-26 08:38:11 executing `multistage:ensure'
  * 2013-06-26 08:38:11 executing `deploy:check'
  * executing test -d /var/www/app/releases
servers: [54.227.250.222]
[54.227.250.222] executing command
command finished in 705ms
  * executing test -w /var/www/app
servers: [54.227.250.222]
[54.227.250.222] executing command
command finished in 710ms
  * executing test -w /var/www/app/releases
servers: [54.227.250.222]
[54.227.250.222] executing command
command finished in 697ms
  * executing which git
servers: [54.227.250.222]
[54.227.250.222] executing command
command finished in 702ms
You appear to have all necessary dependencies installed

$ cap staging deploy
triggering load callbacks
  * 2013-06-26 08:38:49 executing `staging'
triggering start callbacks for `deploy'
  * 2013-06-26 08:38:49 executing `multistage:ensure'
  * 2013-06-26 08:38:49 executing `deploy'
triggering before callbacks for `deploy'
  * 2013-06-26 08:38:49 executing `check_production'
  * 2013-06-26 08:38:49 executing `deploy:update'
 ** transaction: start
  * 2013-06-26 08:38:49 executing `deploy:update_code'
executing locally: git ls-remote g...@github.com:abc/abc.git master
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
*** [deploy:update_code] rolling back
  * executing rm -rf /var/www/app/releases/20130626030853; true
servers: [54.227.250.222]
[54.227.250.222] executing command
command finished in 738ms
Command git ls-remote g...@github.com:abc/abc.git master returned status
code pid 19398 exit 128

I have checked and get to know that it is git configuration problem. I want
to confirm that it is not capsitrano problem ? Do I really need to do git
ssh configuration in my ec2 instance ?


Thanks.

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




Re: [Rails] Capistrano Git SSH problem

2013-06-25 Thread aman mangal
Hi,

You can use your local keys too! have a look here-
https://help.github.com/articles/deploying-with-capistrano

Aman Mangal
3rd year Undergraduate
Department of Computer Science  Engineering
IIT Bombay
www.cse.iitb.ac.in/~amanmangal


On Wed, Jun 26, 2013 at 8:54 AM, news.anand11 news.anan...@gmail.comwrote:

 Hi, I am using Capistrano for deployment. And bitnami in my ec2 linux
 instance. I have configured Capistrano for deployment and deploy:check says
 all is fine. But I am facing problem while doing deploy. Here is the full
 stack

 $ cap deploy:check
 triggering load callbacks
   * 2013-06-26 08:38:11 executing `staging'
 triggering start callbacks for `deploy:check'
   * 2013-06-26 08:38:11 executing `multistage:ensure'
   * 2013-06-26 08:38:11 executing `deploy:check'
   * executing test -d /var/www/app/releases
 servers: [54.227.250.222]
 [54.227.250.222] executing command
 command finished in 705ms
   * executing test -w /var/www/app
 servers: [54.227.250.222]
 [54.227.250.222] executing command
 command finished in 710ms
   * executing test -w /var/www/app/releases
 servers: [54.227.250.222]
 [54.227.250.222] executing command
 command finished in 697ms
   * executing which git
 servers: [54.227.250.222]
 [54.227.250.222] executing command
 command finished in 702ms
 You appear to have all necessary dependencies installed

 $ cap staging deploy
 triggering load callbacks
   * 2013-06-26 08:38:49 executing `staging'
 triggering start callbacks for `deploy'
   * 2013-06-26 08:38:49 executing `multistage:ensure'
   * 2013-06-26 08:38:49 executing `deploy'
 triggering before callbacks for `deploy'
   * 2013-06-26 08:38:49 executing `check_production'
   * 2013-06-26 08:38:49 executing `deploy:update'
  ** transaction: start
   * 2013-06-26 08:38:49 executing `deploy:update_code'
 executing locally: git ls-remote g...@github.com:abc/abc.git master
 Permission denied (publickey).
 fatal: The remote end hung up unexpectedly
 *** [deploy:update_code] rolling back
   * executing rm -rf /var/www/app/releases/20130626030853; true
 servers: [54.227.250.222]
 [54.227.250.222] executing command
 command finished in 738ms
 Command git ls-remote g...@github.com:abc/abc.git master returned status
 code pid 19398 exit 128

 I have checked and get to know that it is git configuration problem. I
 want to confirm that it is not capsitrano problem ? Do I really need to do
 git ssh configuration in my ec2 instance ?


 Thanks.

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




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