[Rails] How do I implement MailCatcher under the docker-compose way?

2020-03-16 Thread Jason Hsu
The app in question is at 
https://github.com/jhsu802701/railn-20200316-215223-398 .  Note that 
config/environments/development.rb is configured for MailCatcher.

I've been able to use MailCatcher without docker-compose, but I can't quite 
figure out how to get it to work in a Rails app that revolves around 
docker-compose.

One solution I tried is to add the 1080:1080 port assignments to the web 
section of docker-compose.yml, but the MailCatcher interface doesn't appear 
at http://localhost:1080/.

Another solution I've tried is to add a mailcatcher section under services 
to make use of a Docker image dedicated to MailCatcher.  While the 
MailCatcher interface does appear, the email messages I expect when I try 
to sign up in my local setup do not materialize.

Exactly what am I missing?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/d32f3288-b923-4aa5-8360-db8288b69d1e%40googlegroups.com.


[Rails] Fully Dockerized Rails apps

2019-11-21 Thread Jason Hsu
Can any of you point me to examples of Rails apps that are fully 
Dockerized?  I'd like to look at as many examples as possible for a good 
reference on how to Dockerize Rails projects that I'm on.

An example is https://github.com/codebar/planner .

Sadly, not all apps with a Dockerfile and a docker-compose.yml file allow 
you to run the test suite in Docker.  Examples include Octobox (
https://github.com/octobox/octobox) and Rubygems.org (
https://github.com/rubygems/rubygems.org).

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/48a6e15d-768b-440e-b89c-76b1c7f70604%40googlegroups.com.


Re: [Rails] Re: How do you run the test suite with docker-compose in a Dockerized Rails app?

2019-10-31 Thread Jason Hsu
Thanks, Walther, on the suggestion of adding a docker container 
specifically dedicated to running tests.  (I personally don't agree with 
the use of Guard, so I'd just run the shell and then enter the test 
commands when necessary.)  Why isn't this normally done?

But exactly what is the docker-compose command for running the test suite 
on Octobox?  Every time I've tried to run the test suite with a 
docker-compose command, I get stopped in my tracks by an error message 
telling me that simplecov isn't loading.  For reasons I haven't been able 
to figure out, the simplecov gem doesn't get installed when I enter "bundle 
install" even though it's in the Gemfile and Gemfile.lock.  I even tried 
starting a Docker container to run an sh shell, and running "bundle 
install" didn't install the simplecov gem.

On Thursday, October 31, 2019 at 6:13:23 AM UTC-5, walt wrote:
>
> IMHO “.., I use just one Docker container” is the first order of (your) 
> business to get straighten out :)
>
> Using containers with Rails is quite a feast - and an added bonus is that 
> once set up you have next to zero footprint on your ‘own’ computer (that is 
> a blatant lye ‘cause your code base needs to sit somewhere, and the docker 
> images has to be in place too - but even that could be ‘clouded’)
>
> Docker containers doesn’t really start to shining until you let them ;)
>
> That is - delegate delegate delegate - or: one container per “task” 
>
> You’ll have at least three containers spinning - again IMHO. An app 
> container with the Puma webserver serving the Rails stuff, a database 
> container for the Rails models to persist their data, and a container for a 
> reversed NgINX proxy serving clients on 80/443 and forwarding the necessary 
> requests to the ‘animal’ (Puma). Other container candidates are: Redis, 
> Sidekiq, and memcached. Here are the observations by Cloud66 - 
> https://blog.cloud66.com/containers-for-rails-developers-use-containers-while-staying-true-to-your-ror-roots/
>  
> 
>
> Use hub.docker.com to load the necessary images, then use github.com to 
> load the codebase, then 
>
> docker-compose build
> docker-compose up (-d if you’d like it to sit in the background=daemonized)
>
> That’s it - more or less
>
> Getting there will take you through one/two hoops I know for sure but it’s 
> worth the journey!
>
> Start by following this example: 
> https://www.chrisblunt.com/ruby-on-rails-running-tests-with-guard-and-docker/
>  
>
> Chris Blunt did an excellent demonstration job!
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/f91bed88-c4fc-4230-91e2-61da850b0c80%40googlegroups.com.


Re: [Rails] Re: How do you run the test suite with docker-compose in a Dockerized Rails app?

2019-10-30 Thread Jason Hsu
Yes.  However, I use just one Docker container that contains everything I 
need, including Ruby, Rails, Node.js, PostgreSQL, Redis, etc.  I know that 
my way is crude, but it works.  I can't move on to the docker-compose way 
of doing things until I figure out all the issues that are stopping me.

On Wednesday, October 30, 2019 at 11:07:06 AM UTC-5, Brandon McClelland 
wrote:
>
> You said "When I log into my custom Docker container, I basically follow 
> the same procedure that the people who rely on their host environments do." 
> Can you run the tests successfully that way?
>
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/5a60f0c7-2dfe-4b03-8a71-679901587b59%40googlegroups.com.


Re: [Rails] Re: How do you run the test suite with docker-compose in a Dockerized Rails app?

2019-10-30 Thread Jason Hsu
I thought that would work, but simplecov isn't loading.


On Wednesday, October 30, 2019 at 10:53:06 AM UTC-5, Brandon McClelland 
wrote:
>
> You would do something like this (found at 
> https://blog.codeship.com/testing-rails-application-docker/ after 
> googling "running rails test with docker-compose run"):
>
> docker-compose run -e "RAILS_ENV=test" app rake test
>
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/7bbfbc49-cf34-41ee-9f4b-f9415e631c44%40googlegroups.com.


[Rails] Re: How do you run the test suite with docker-compose in a Dockerized Rails app?

2019-10-30 Thread Jason Hsu
What's the full command for running the test suite?  Sadly, but this isn't 
a CS class that one can BS through with partial credit.

On Wednesday, October 30, 2019 at 7:25:06 AM UTC-5, San Ji wrote:
>
> docker-compose run?
>
> https://docs.docker.com/compose/reference/run/
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/9d2fcfc0-b32b-4008-87ea-61e64212fbed%40googlegroups.com.


[Rails] How do you run the test suite with docker-compose in a Dockerized Rails app?

2019-10-29 Thread Jason Hsu
I've contributed to the Octobox app (https://github.com/octobox/octobox).  
I've been using a weird system of using Docker.  Instead of using it the 
normal way, I create my own custom Docker image for each Rails project that 
I'm on.  When I log into my custom Docker container, I basically follow the 
same procedure that the people who rely on their host environments do.

I'm trying to learn the more conventional way of using Docker with 
docker-compose, but I'm having difficulty finding out how you're supposed 
to run the test suite.

I've followed the instructions at 
https://github.com/octobox/octobox/blob/master/docs/INSTALLATION.md#using-docker-and-docker-compose
 
.  While I've been able to get the development environment working, I have 
not been able to figure out how I'm supposed to run the test suite with the 
docker-compose command.  Exactly what is the command for running the test 
suite?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/4acb9ce6-c5d3-4056-99b0-6e21c704ff03%40googlegroups.com.


[Rails] Rails 5.2 Custom Credentials — generally accepted way to segregate environments?

2019-06-09 Thread Jason Fleetwood-Boldt
In some apps I've worked on Rails 5.1 and prior, environment variables, 
saved directly into the source code.

In rails 5.2 Custom credentials encourages us to check-in only the 
encrypted version of our configuration, and keep our master.key keyfile 
outside of our repository. 

My question is this: Is there a way to segregate by environment? (i.e., 
development, staging, production?)

seems like the instructions for setting up AWS keys, for example, would 
have the dev, staging + production all pointing to & using the same AWS 
bucket, access key, and secret. But it seems like for many services I'd 
want to have different credentials for different environments. 

I found this SO post that discusses this question, but unfortunately it 
doesn't present a very good answer IMHO because the there are only two 
answers: 1) I don't quite understand and 2) a suggestion to basically check 
all your ENV variables against each of your environments, which seems like 
it could encourage a messy setup. I much like answer #1 from this SO post, 
but I don't understand how to implement it practically. 

https://stackoverflow.com/questions/53642152/how-to-manage-credentials-for-different-environments-in-rails-5-2

any tip appreciated. 
Thanks,
Jason

-- 
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/4577e3bb-754c-48bc-8fe3-f8fddda77481%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Working on the rubygems.org web site

2019-04-01 Thread Jason Hsu
Do any of you work on the rubygems.org web site?  The repository URL is at 
https://github.com/rubygems/rubygems.org .

I'm able to get all but THREE tests to pass.  All of these tests fail with 
the message "Failed to open TCP connection to localhost:1".  I've 
described my dilemma in more detail at 
https://github.com/rubygems/rubygems.org/issues/1782 .

The official way of working on this app is to have Ruby on Rails installed 
in the host OS and use Docker to run ElasticSearch.  PLEASE don't tell me 
to do it this way.  Manually installing Ruby on Rails in the host OS is a 
long and painful process.  The deal-breaker is not being able to reset the 
development environment willy-nilly.

I tried to install Docker within Docker, but this didn't pan out.  Thus, 
having Rails in a Docker container and ElasticSearch in a Docker container 
within a Docker container is a no-go.

So now what I'm trying is ElasticSearch in the same Docker container where 
I'm running Rails.  I know that /etc/elasticsearch/elasticsearch.yml is the 
configuration file, but trying to set transport.host in it hasn't panned 
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/9da8ec13-db0f-4041-bc53-3eae3b24315f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Is there a way to replicate the Travis CI build environment?

2019-03-30 Thread Jason Hsu
I'm trying to contribute to several open source projects, but I'm unable to 
get them working on my local machine.  Fortunately, these open source 
projects use Travis CI.  Unfortunately, I don't know how to replicate the 
Travis CI environment on my local machine, even with the use of Docker 
images I've created myself, which don't really replicate the setup.

Are the Docker images used by Travis CI publicly available?

-- 
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/6b47d390-97a7-470c-86da-e0a74e0ee45c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] How do I update someone else's fork?

2019-01-28 Thread Jason Hsu
I'm on the RailsBridge Bridge Troll project at 
https://github.com/railsbridge/bridge_troll.  I am NOT a collaborator.  My 
fork is at https://github.com/jhsu802701/bridge_troll.

Someone else submitted a pull request that is now lagging several commits 
behind the upstream master branch.  This pull request is at 
https://github.com/railsbridge/bridge_troll/pull/580.

How do I sync up the branch behind this pull request?

-- 
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/a571effe-1895-45cf-805a-cd07ff541f0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] When tests pass in CI but fail in the development environment

2019-01-23 Thread Jason Hsu
I understand that if your app's tests fail in the continuous integration 
environment but pass in your development environment, you should figure out 
why tests fail in CI and NOT blow off the matter.

What should you do when the reverse is true - when tests pass in CI but not 
in your local development environment?  Do you blow off testing in the 
local environment, push your changes to an alternate branch, and see if 
things pan out in the CI environment?  Maybe this is appropriate in some 
situations, but it sounds like a cop-out to me.

-- 
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/3b5c0b69-639b-4c93-b79f-6d3e461bbd4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Thankful for Ruby 2.6.0

2019-01-17 Thread Jason Hsu
I'm so thankful for the recent release of Ruby 2.6.0, which has allowed me 
to move on from 2.5.0.

When trying to start a new app on a system with Ruby 2.5.0 and 2.5.3, I'd 
get messages like "Your Ruby version is 2.5.3, but your Gemfile specified 
2.5.0" and "Your Ruby version is 2.5.0, but your Gemfile specified 2.5.3".  
I'd check the Gemfile, my Ruby version, the .rbenv-version file, etc.  But 
no matter how correct these configurations were, I couldn't get things to 
work.  I also had similar problems when trying to upgrade an existing app 
from Ruby 2.5.0 to 2.5.3.

In contrast, I have no such problems with upgrading to Ruby 2.6.0.  I just 
hope that rest of the Ruby 2.6.x series doesn't give me the same problems 
and force me to wait for Ruby 2.7.0.

-- 
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/343a808d-40d1-41cb-9321-2dd6c7e0e9bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Re: Logging in as a seeded user in an OmniAuth app

2019-01-10 Thread Jason Hsu
The test environment already has the ability to log in as a user other than 
myself.  I'm trying to get my localhost/development setup to do the same 
thing by running a Ruby script.

On Thursday, January 10, 2019 at 4:43:59 PM UTC-6, Rob Jonson wrote:
>
> bypass_sign_in is intended to be used from a controller where you'll have 
> access to things like 'session'
> I suggest you start by getting it working in the intended environment 
> before you try to pull it out into a standalone script.
>
> On Thu, 10 Jan 2019 at 22:16, Jason Hsu > 
> wrote:
>
>> OK, I'm trying out the bypass_sign_in feature.  I'm getting the following 
>> error:
>> /home/winner/.rbenv/gems/2.6.0/gems/devise-4.5.0/lib/devise/controllers/
>> sign_in_out.rb:112:in `expire_data_after_sign_in!': undefined local 
>> variable or method `session' for main:Object (NameError)
>>
>> I've put the script login.rb in the root directory of the project.  The 
>> code of login.rb is:
>> require File.expand_path('../config/environment', __FILE__)
>> require 'devise'
>> include Devise::Controllers::SignInOut
>>
>> users = User.all;
>> num_users = User.count;
>> n_first = 0;
>> n_last = num_users - 1;
>>
>> puts '---'
>> puts 'Logging in as a seeded user'
>> puts ''
>> puts "Pick a user number from #{n_first} to #{n_last}:"
>> n_input = gets.chomp().to_i;
>> @user = users[n_input];
>> puts @user
>>
>> bypass_sign_in @user, scope: :user
>>
>> Everything works as expected until the bypass_sign_in.  Is there another 
>> "require" or "include" statement that I need to add?
>>
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "Ruby on Rails: Talk" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/rubyonrails-talk/d85MICj-BJQ/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, send an email to 
>> rubyonrails-ta...@googlegroups.com .
>> To post to this group, send email to rubyonra...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/rubyonrails-talk/21df3d80-5f5b-4f60-a28a-0bd6d4e5a13d%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/rubyonrails-talk/21df3d80-5f5b-4f60-a28a-0bd6d4e5a13d%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
>
>
>
>
>
> Hobbyist Software is a trading name of Hobbyist Software Limited. 
> Registered office 12 Fraley Rd, Bristol, BS93BS. Registered in England. 
> Company no:7876492
>

-- 
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/b6c29750-0729-4b96-a897-d0a086efb132%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Logging in as a seeded user in an OmniAuth app

2019-01-10 Thread Jason Hsu
OK, I'm trying out the bypass_sign_in feature.  I'm getting the following 
error:
/home/winner/.rbenv/gems/2.6.0/gems/devise-4.5.0/lib/devise/controllers/
sign_in_out.rb:112:in `expire_data_after_sign_in!': undefined local 
variable or method `session' for main:Object (NameError)

I've put the script login.rb in the root directory of the project.  The 
code of login.rb is:
require File.expand_path('../config/environment', __FILE__)
require 'devise'
include Devise::Controllers::SignInOut

users = User.all;
num_users = User.count;
n_first = 0;
n_last = num_users - 1;

puts '---'
puts 'Logging in as a seeded user'
puts ''
puts "Pick a user number from #{n_first} to #{n_last}:"
n_input = gets.chomp().to_i;
@user = users[n_input];
puts @user

bypass_sign_in @user, scope: :user

Everything works as expected until the bypass_sign_in.  Is there another 
"require" or "include" statement that I need to add?

-- 
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/21df3d80-5f5b-4f60-a28a-0bd6d4e5a13d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Logging in as a seeded user in an OmniAuth app

2019-01-07 Thread Jason Hsu
Here's an example:
I'm working on the CodeTriage app 
(https://github.com/codetriage/codetriage).  I have CodeTriage working and 
passing tests in my local development environment.

In this app, GitHub authentication is the sole authentication option. To 
avoid being automatically logged in in the localhost environment, I can log 
out of GitHub in my browser or open up the localhost site in private to get 
the option to log in. However, clicking on the "Log in" option then takes 
me to https://github.com/login, which means that I can only log in as 
myself and not one of the seeded users.


Given this, what's the procedure to log in as one of the seeded users?

-- 
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/757758bc-fe82-4a0d-916c-1832c3ade1d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Reasons to NOT have a test coverage badge

2019-01-03 Thread Jason Hsu
I'm already familiar with the reasons to have a test coverage badge in each 
Rails project.  While I'm sure that the test coverage measurements have 
limitations, I believe that it's better to have a test coverage than to not 
have one.

However, I've learned that an open source project that I'm working on used 
to have a test coverage badge but no longer does.  What is the case AGAINST 
test coverage badges?

-- 
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/6b61f51a-030b-47a8-8121-14711d17172d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Comment in the Blog test project

2018-12-26 Thread jason cao
Hi,

How can I show error messages if a comment is invalid? E.g. when a comment 
body is empty. I add validation in the model class, and the validation 
itself works, but it won't show any error message. Can you please help? 
Many thanks!

Regards,
Jason

-- 
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/2abe97f7-2e6b-452b-85d9-a9980d6982fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Reasons to NOT add ".DS_Store" to the .gitignore file

2018-12-13 Thread Jason Hsu
I'm contributing to an open source Rails app.  I submitted a pull request 
to add .DS_Store to the .gitignore file.  The purpose is to prevent people 
from accidentally adding the .DS_Store to the source code.  Some people are 
objecting to this, saying that it's easy to use global gitignore.

While this doesn't directly affect me (since I use Linux instead of MacOS), 
I've made removing .DS_Store and adding .DS_Store to the .gitignore file to 
be a standard part of joining a Rails app.  If you use my Rails Neutrino 
tool (https://www.railsneutrino.com/) or Generic App gem 
(https://www.genericapp.net/) to start a new Rails app, you start off with 
.DS_Store already in the .gitignore file.

Global gitignore on MacOS may be easy to use, but I still don't understand 
the objection to adding .DS_Store to .gitignore.  Can any of you shed some 
light on why people might NOT want .DS_Store listed in .gitignore?  Is it 
really that beneficial to keep the .gitignore file as short as possible?  
It seems to me that it's better to have .DS_Store in .gitignore than risk 
facing the annoyance of accidentally committed .DS_Store files later.  Can 
you really count on everyone to have global gitignore set?

-- 
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/d0bc075d-7dcb-4230-bde8-52ff634bf20b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Can start a new Rails app with Ruby 2.5.0 but not in 2.5.3

2018-11-28 Thread Jason Hsu
My development environment has rbenv with Ruby 2.5.0 and 2.5.3.  I can 
start a new Rails app in Ruby 2.5.0 but not in Ruby 2.5.3.  Here's the 
script I'm using for creating a quick and dirty Rails app:
```
#!/bin/bash

# This script creates a basic Rails app that uses an SQLite database.
# PURPOSE: Provide confirmation that Ruby on Rails is properly set up.

# This is the same test app as the one at 
http://elinux.org/RPi_Ruby_on_Rails .
cd /home/winner/shared && rails new school_sq --skip-spring
cd /home/winner/shared/school_sq && rails g scaffold Pupil name:string 
form:string
cd /home/winner/shared/school_sq && rake db:migrate

echo '**'
echo 'OPEN YOUR WEB BROWSER.'
echo 'GO TO THE FOLLOWING URL:'
echo 'http://localhost:3000/pupils'

echo '***'
echo 'IMPORTANT NOTE:'
echo 'The port number listed above assumes a zero offset for the port 
number.'
echo 'If you are using a non-zero offset in Docker,' 
echo 'you must adjust the above port number accordingly.'
echo '**'

echo ''
cat /home/winner/shared/ports.txt
echo ''

echo 
'*'
echo "You can use access the database in this app's db/development.sqlite3 
file"
echo 'by using SQLite database browser.'
echo '*'
cd /home/winner/shared/school_sq && rails s -b 0.0.0.0 -p 3000
```

When I run this script in Ruby 2.5.0, I have no problems.  Everything works 
as expected.

But when I run this script in Ruby 2.5.3 (rbenv global 2.5.3), I keep 
getting error messages:
1.  When I first run the script, I get the message "Your Ruby version is 
2.5.3, but your Gemfile specified 2.5.0" during the "bundle install" part.  
It turns out that the Gemfile specifies Ruby 2.5.0.  (WHY does Rails app 
generator insist on Ruby 2.5.0 instead of 2.5.3?)
2.  When I correct the Gemfile, I get the message "Your Ruby version is 
2.5.0, but your Gemfile specified 2.5.3" when I run "rails db:migrate".
3.  When I enter "bin/rails db:migrate RAILS_ENV=development", the error 
message doesn't appear.  However, I get the message "Your Ruby version is 
2.5.0, but your Gemfile specified 2.5.3" when I enter "rails s -b 0.0.0.0 
-p 3000".

I have some apps in Ruby 2.5.0.  I want to upgrade them to 2.5.3, but I get 
a similar conundrum.  So I'm sticking with Ruby 2.5.0, because stagnation 
is better than breakage.

Why is Ruby 2.5.3 such a problem?  Should I just wait for 2.6.0 to be 
released before upgrading?

-- 
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/13ff8729-0090-4d5f-937f-8c875c94b92d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Test coverage in Rails apps

2018-10-21 Thread Jason Hsu, Ruby on High Speed Rails
Thanks, Rob!  Entering "DISABLE_SPRING=1 rails test" gives me the 93.16% 
test coverage.

Exactly what is the significance of the Spring server?  Why isn't Rails set 
up to automatically take care of this?

On Saturday, October 20, 2018 at 9:39:11 AM UTC-5, Rob Zolkos wrote:
>
> In development run your tests with the DISABLE_SPRING=1 flag before the 
> test command and see if you see a difference in coverage.
>
> On Sun, Oct 21, 2018 at 12:17 AM Jason Hsu, Ruby on High Speed Rails <
> jhsu8...@gmail.com > wrote:
>
>> How can I get test coverage results to show more consistent results that 
>> make sense?
>>
>> I earlier decided against having SimpleCov and test coverage badges in my 
>> Rails apps.  It seemed that no matter how I configured SimpleCov, there 
>> were some glaring flaws in its results.  However, I have since changed my 
>> mind as a result of working on a legacy Rails app that had very sparse test 
>> coverage when I first joined.  SimpleCov showed only 25% test coverage.  As 
>> a result, I've decided to make test coverage a standard part of all Rails 
>> apps I'm on.  Test coverage metrics may have their flaws, but I figure that 
>> test coverage results should flag the parts of the test suite that need the 
>> most improvement.
>>
>> So I've added test coverage to my new Ruby.MN app.  The production site 
>> is at http://rubymn2.herokuapp.com/, and the source code is at 
>> https://github.com/jhsu802701/rubymn2 .  Currently, the CodeCov badge 
>> shows 93% test coverage, and the results make sense to me.
>>
>> However, SimpleCov in my local development environment shows test 
>> coverage of only 76%.  In fact, it doesn't recognize ANY of my user or 
>> admin model tests.  CodeCov does, and this is why it shows a much better 
>> test coverage figure.
>>
>> What's going on?  Why is there such a big discrepancy?  How can I 
>> configure SimpleCov to show results that make more sense?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ruby on Rails: Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to rubyonrails-ta...@googlegroups.com .
>> To post to this group, send email to rubyonra...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/rubyonrails-talk/e6a363bb-0bc0-4c81-94a1-0b58d8ac3fec%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/rubyonrails-talk/e6a363bb-0bc0-4c81-94a1-0b58d8ac3fec%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


[Rails] Test coverage in Rails apps

2018-10-20 Thread Jason Hsu, Ruby on High Speed Rails
How can I get test coverage results to show more consistent results that 
make sense?

I earlier decided against having SimpleCov and test coverage badges in my 
Rails apps.  It seemed that no matter how I configured SimpleCov, there 
were some glaring flaws in its results.  However, I have since changed my 
mind as a result of working on a legacy Rails app that had very sparse test 
coverage when I first joined.  SimpleCov showed only 25% test coverage.  As 
a result, I've decided to make test coverage a standard part of all Rails 
apps I'm on.  Test coverage metrics may have their flaws, but I figure that 
test coverage results should flag the parts of the test suite that need the 
most improvement.

So I've added test coverage to my new Ruby.MN app.  The production site is 
at http://rubymn2.herokuapp.com/, and the source code is at 
https://github.com/jhsu802701/rubymn2 .  Currently, the CodeCov badge shows 
93% test coverage, and the results make sense to me.

However, SimpleCov in my local development environment shows test coverage 
of only 76%.  In fact, it doesn't recognize ANY of my user or admin model 
tests.  CodeCov does, and this is why it shows a much better test coverage 
figure.

What's going on?  Why is there such a big discrepancy?  How can I configure 
SimpleCov to show results that make more sense?

-- 
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/e6a363bb-0bc0-4c81-94a1-0b58d8ac3fec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Re: Git forking: adding elements to my personal repository but not the original

2018-08-28 Thread Jason Hsu, Ruby on High Speed Rails
Yes, I'm talking about GitHub.  I know how to fork a project.  I can create 
a new branch and then submit the branch as a pull request.

What I'm not clear on is how to add elements to the project (like the Bash 
scripts and Ruby gems) to my version of the project, submit a pull request 
that omits these particular personal elements, and update my version of the 
project from the original WITHOUT losing my personal elements.

-- 
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/35b9e2ab-f9e1-499a-b895-31dc708d1183%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Git forking: adding elements to my personal repository but not the original

2018-08-28 Thread Jason Hsu, Ruby on High Speed Rails
Let's say that the project I'd like to work on is other_user/project1.  I 
clone this project, and my version is myself1/project1.  How do I proceed?

-- 
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/3d9a72df-4230-4f5b-af17-50d571f4ae6f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Git forking: adding elements to my personal repository but not the original

2018-08-28 Thread Jason Hsu, Ruby on High Speed Rails
As you know, a way to contribute to a project without being a collaborator 
is to fork a project, create a branch, make the changes in your new branch, 
and submit the new branch as a pull request.

There are certain things I'd like to add to a project (like Bash scripts 
and the annotate, rails-erd, and railroady gems), but the project 
collaborators don't want them.  I understand now that they don't expect me 
to suck it up and do things their way.  Instead, they want me to keep those 
features on just my own personal branch but push other changes.

How do I go about doing this?  Do I make the changes to my personal fork's 
master branch or a different branch?  When the upstream repository is 
updated, how do I update my personal branch to incorporate these changes 
WITHOUT wiping out my personal features?

-- 
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/dd563618-24c8-408c-b0aa-12a41f50bdf5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] ActiveRecord model name conflicts with with instance method name

2018-07-25 Thread Jason Taylor
Oh wow, even easier an more succinct than I expected the answer to be!  
Thanks so much for the feedback.


On Wednesday, July 25, 2018 at 6:38:05 AM UTC-6, Bruno Oliveira wrote:
>
> Hi, Jason. You can keep the name. The only difference is that you will 
> have to change the relationship indication. 
>
> belongs_to: my_transaction, class_name: "Transaction", foreign_key: 
> "transaction_id"
>
> Em Qua, 25 de jul de 2018 02:44, Jason Taylor  > escreveu:
>
>> Hello all,
>>
>> I'm currently working on upgrading our application to Rails 4.1 and am 
>> running into the following scenario.
>>
>> We have an existing model named `Transaction` which conflicts with the 
>> ActiveRecord instance method of the same name when we refer to this model 
>> in a `belongs_to` association like this:
>>
>> ```
>> class Transaction < ActiveRecord::Base
>> end
>>
>> class Thing < ActiveRecord::Base
>>   belongs_to :transaction
>> end
>> ```
>>
>> This will trigger this error: "You tried to define an association named 
>> transaction on the model Thing, but this will conflict with a method 
>> transaction already defined by Active Record. Please choose a different 
>> association name."
>>
>> As far as I can tell, the `transaction` instance method has existed in 
>> ActiveRecord since Rails 3.x but this error was added in 4.1.0.rc1 as shown 
>> here: https://github.com/rails/rails/pull/13896
>>
>> My question is twofold:
>>
>> 1) Is there a convenient way to rename an association like this without 
>> having to change the model name, db table name, etc?
>>
>> 2) Why is `ActiveRecord::Base#transaction` available as an instance 
>> method in the first place?  Seems like this is best implemented as a class 
>> method and in fact the instance method version in ActiveRecord just calls 
>> the class method version anyway (see here: 
>> https://github.com/rails/rails/blob/master/activerecord/lib/active_record/transactions.rb#L299-L302
>> ).
>>
>> The word "Transaction" seems as though it would be a commonly used model 
>> name for many Rails applications so I'm just trying to gain an 
>> understanding of why this would be taken by ActiveRecord.
>>
>> Thanks,
>> Jason
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ruby on Rails: Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to rubyonrails-ta...@googlegroups.com .
>> To post to this group, send email to rubyonra...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/rubyonrails-talk/e2a741ff-0400-46d6-91be-ca72b682fa51%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/rubyonrails-talk/e2a741ff-0400-46d6-91be-ca72b682fa51%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


[Rails] ActiveRecord model name conflicts with with instance method name

2018-07-24 Thread Jason Taylor
Hello all,

I'm currently working on upgrading our application to Rails 4.1 and am 
running into the following scenario.

We have an existing model named `Transaction` which conflicts with the 
ActiveRecord instance method of the same name when we refer to this model 
in a `belongs_to` association like this:

```
class Transaction < ActiveRecord::Base
end

class Thing < ActiveRecord::Base
  belongs_to :transaction
end
```

This will trigger this error: "You tried to define an association named 
transaction on the model Thing, but this will conflict with a method 
transaction already defined by Active Record. Please choose a different 
association name."

As far as I can tell, the `transaction` instance method has existed in 
ActiveRecord since Rails 3.x but this error was added in 4.1.0.rc1 as shown 
here: https://github.com/rails/rails/pull/13896

My question is twofold:

1) Is there a convenient way to rename an association like this without 
having to change the model name, db table name, etc?

2) Why is `ActiveRecord::Base#transaction` available as an instance method 
in the first place?  Seems like this is best implemented as a class method 
and in fact the instance method version in ActiveRecord just calls the 
class method version anyway (see here: 
https://github.com/rails/rails/blob/master/activerecord/lib/active_record/transactions.rb#L299-L302).

The word "Transaction" seems as though it would be a commonly used model 
name for many Rails applications so I'm just trying to gain an 
understanding of why this would be taken by ActiveRecord.

Thanks,
Jason

-- 
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/e2a741ff-0400-46d6-91be-ca72b682fa51%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Continuous integration for BitBucket/GitLab

2018-07-12 Thread Jason Hsu, Ruby on High Speed Rails
Have any of you made the switch from GitHub to BitBucket or GitLab?  What 
are you using for integration services?  Hakiri and CodeClimate seem to 
support only GitHub.

-- 
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/12f65330-1087-401e-978e-5f8fdffd3afd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] newbie: copy file from github to local directory?

2018-06-06 Thread Jason McMahan
Would this code work or am i way off?

setcode do
  if File.exist? '/etc/udev/rules.d/66-azure-storage.rules'
  #do something
  else
download = 
open('https://github.com/Azure/WALinuxAgent/blob/master/config/66-azure-storage.rules')
IO.copy_stream(download, '/etc/udev/rules.d/66-azure-storage.rules')
 #do something
  end
end


On Wednesday, June 6, 2018 at 5:56:43 AM UTC-5, Jason McMahan wrote:
>
> The url is 
> https://github.com/Azure/WALinuxAgent/blob/master/config/66-azure-storage.rules
>
> I thought something along the lines of 
>
> if File.exist? '/etc/udev/rules.d/66-azure-storage.rules'
>   setcode do
>#*something*
>   end
> else
>   #Copy file from url to /etc/udev/rules.d/66-azure-storage.rules
>   #then do something.
> end
>
> Thank you all the quick replies and help thus far it is appreciated.
>
> On Tuesday, June 5, 2018 at 4:15:08 PM UTC-5, Hassan Schroeder wrote:
>>
>> On Tue, Jun 5, 2018 at 1:14 PM, Jason McMahan  
>> wrote: 
>>
>> > I am new to rails and would like suggestions/help to copy a file from 
>> github 
>> > to a local directory. 
>>
>> Not a Rails question at all, but assuming you know the URL of the 
>> file you want to retrieve: 
>>
>>   https://ruby-doc.org/stdlib-2.5.1/libdoc/open-uri/rdoc/OpenURI.html 
>>
>> -- 
>> Hassan Schroeder  hassan.s...@gmail.com 
>> twitter: @hassan 
>> Consulting Availability : Silicon Valley or remote 
>>
>

-- 
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/87e0ac94-1633-4066-94f1-a62d339281ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] newbie: copy file from github to local directory?

2018-06-06 Thread Jason McMahan
The url 
is 
https://github.com/Azure/WALinuxAgent/blob/master/config/66-azure-storage.rules

I thought something along the lines of 

if File.exist? '/etc/udev/rules.d/66-azure-storage.rules'
  setcode do
   #*something*
  end
else
  #Copy file from url to /etc/udev/rules.d/66-azure-storage.rules
  #then do something.
end

Thank you all the quick replies and help thus far it is appreciated.

On Tuesday, June 5, 2018 at 4:15:08 PM UTC-5, Hassan Schroeder wrote:
>
> On Tue, Jun 5, 2018 at 1:14 PM, Jason McMahan  > wrote: 
>
> > I am new to rails and would like suggestions/help to copy a file from 
> github 
> > to a local directory. 
>
> Not a Rails question at all, but assuming you know the URL of the 
> file you want to retrieve: 
>
>   https://ruby-doc.org/stdlib-2.5.1/libdoc/open-uri/rdoc/OpenURI.html 
>
> -- 
> Hassan Schroeder  hassan.s...@gmail.com 
>  
> twitter: @hassan 
> Consulting Availability : Silicon Valley or remote 
>

-- 
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/d34da507-c63b-453e-82b6-36adeac1c614%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] newbie: copy file from github to local directory?

2018-06-05 Thread Jason McMahan
Good day,
I am new to rails and would like suggestions/help to copy a file from 
github to a local directory.

I assume use the FileUtils but any help would be appreciated.

Thank you

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


[Rails] Creating RSpec factory objects for the ENTIRE test suite

2018-06-02 Thread Jason Hsu, Ruby on High Speed Rails
There are plenty of examples on how to create RSpec factory objects for 
just one set of tests.

Is there a way to create RSpec factory objects that are good across ALL 
tests (including ALL integration and controller tests)?  This is necessary 
for a project to work on, because the process of creating some of these 
objects involves parsing large spreadsheet files.  Having to create these 
objects over and over again takes too long.  Thus, I need a way to create 
these objects just once and use them for all tests that need them.

-- 
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/eb23344d-a21a-497b-b78c-4768f1528479%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: reading windows environment variables

2018-05-16 Thread Jason McMahan
In Irb i am able to run

ENV['OvInstallDir']

Returns the correct path 'c:\program files\'

THank you for any further help.

On Wednesday, May 16, 2018 at 12:57:47 PM UTC-5, Jason McMahan wrote:
>
> Could someone please suggest how i could read environment variables from 
> windows?
> In cmd i can run 
>
> "%ovinstalldir%bin\win64\test.bat" -version
>
> However i am attempting to do the same in the irb and not sure how i 
> should do that.
>
> Any help is greatly appreciated.
>
> Thank you
>

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


[Rails] reading windows environment variables

2018-05-16 Thread Jason McMahan
Could someone please suggest how i could read environment variables from 
windows?
In cmd i can run 

"%ovinstalldir%bin\win64\test.bat" -version

However i am attempting to do the same in the irb and not sure how i should 
do that.

Any help is greatly appreciated.

Thank you

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


[Rails] active directory group help please

2018-05-03 Thread Jason McMahan
Good day, 
I am new to Ruby but it is used for types and providers in puppet.
I am attempting to fix a module that isnt working.

def exists?
self.class.send_log(:info, "call exists?")
begin
myreturnvalue =   powershell([ "import-module 
activedirectory;","Get-ADGroup -Filter {(name -eq 
\"#{@resource[:name]}\")}"])
self.class.send_log(:debug, "Get-ADGroup: The return value is : 
#{myreturnvalue} ")

if myreturnvalue == ""
false
else
true
end
rescue Puppet::ExecutionFailure => e
self.class.send_log(:err, "Error In Commands: " )
false
end
end

That is the method used to check if exists.

It returns a group, then the module has 
def name
"\"" + @resource[:name].to_s + "\""
end

def path
"\"" + @resource[:path].to_s + "\""
end

def desc
   "\"" + @resource[:desc].to_s + "\""
end
def desc=(value)
end

def group_scope
"\"" + @resource[:group_scope].to_s + "\""
end
def group_scope=(value)
end

def group_category
"\"#{@resource[:group_category]}\""
end
def group_category=(value)
end

When this is run, ever time it makes "changes" that arent changes really.
desc changed '"Windows AD Group Managed by Puppet"' to 'Windows AD Group 
Managed by Puppet'
or 
group_scope changed "\"DomainLocal\"" to :DomainLocal
or
group_category changed '"Security"' to 'Security'

I assume in the define it is appending "" on description that really isnt 
there and then compare see it is different.

Any help, documentation or guidance would be greatly appreciated. 

Thank you

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


[Rails] A Rails tutorial with much shorter chapters

2018-02-26 Thread Jason Hsu, Ruby on High Speed Rails
Check out my Ruby on Rails tutorial 
at https://github.com/jhsu802701/tutorial-rails-rubymn2 .  It was inspired 
by Michael Hartl's Rails Tutorial and chronicles the process I used for 
building a new Rails site for Ruby Users of Minnesota.

Like Rails Tutorial, my tutorial features test-driven development.  Unlike 
Rails Tutorial, my tutorial features short chapters to ensure that you 
don't get lost.

Let me know what you think.  If you find bugs, please submit issues to the 
tutorial source code.

-- 
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/cbf27eb7-52f7-467f-ac8e-221bd69c0b1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Ruby gem's executable "setup" conflicts with another gem

2017-08-20 Thread Jason Hsu, Ruby on High Speed Rails
The gem in question is GenericApp 
(https://github.com/jhsu802701/generic_app/).

When I enter the command "gem install generic_app", I get the following 
error message:
generic_app's executable "setup" conflicts with string_in_file

string_in_file is a gem used by generic_app.  But for the life of me, I 
cannot see how it can possibly conflict with the bin/setup script in my 
GenericApp project.  Can anyone shed some light on this?

-- 
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/c393e3c5-c5e2-4cc0-b26b-2099613843f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Ruby on Racetracks tutorials

2017-08-20 Thread Jason Hsu, Ruby on High Speed Rails
Check out my tutorials on much faster ways to get started in Ruby on Rails 
at http://www.rubyonracetracks.com/tutorials.html .  Thanks to Docker, you 
can have Ruby on Rails ready to roll in minutes, not hours.  Thanks to 
VirtualBox, you don't need to install Ruby on Rails in Windows or figure 
out how to make Bash scripts work in Windows.

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


[Rails] Rails 4.0 + Rails 4.1 CSRF problems affecting IE 11, Edge, newer versions of Android and mobile Safari

2017-08-07 Thread Jason Fleetwood-Boldt
Rails community,

I have been investigating and debugging a serious, widespread problems with our 
Rails 4.1 app (I realize Rails 4.1 is no longer supported, see below.)

This is not a simple "pass the CSFR token from the form to the controller" 
question. 

This appears to me to be a serious, widespread architectural flaw in Rails 4.0 
and Rails 4.1 that appear to basically make those versions of Rails essentially 
incompatible with newer browsers. (The newer browsers, by the way, appear not 
to be respecting Cache-control headers, which looks to me the like the root of 
the problem)

The problem is detailed here:

https://stackoverflow.com/questions/45329731/csrf-tokens-to-not-match-what-is-in-session-rails-4-1?noredirect=1#comment77622671_45329731
 
<https://stackoverflow.com/questions/45329731/csrf-tokens-to-not-match-what-is-in-session-rails-4-1?noredirect=1#comment77622671_45329731>


Quick question: 

As explained here, I understand that the CSRF implementation to be different in 
Rails 5. Specifically, each form gets its own token. My question is this: Does 
this new design in Rails 5 eliminate or lessen the symptom described in my SO 
post above?

If so, this would be a compelling reason for us to upgrade to Rails 5, as we 
think we are loosing a significant amount of traffic due to this bug. 

If not, I am wondering if others are seeing this too and what can be done to 
address this issue. 

-Jason






Jason Fleetwood-Boldt
t...@datatravels.com
http://www.jasonfleetwoodboldt.com/writing

If you'd like to reply by encrypted email you can find my public key on 
jasonfleetwoodboldt.com <http://jasonfleetwoodboldt.com/> (more about setting 
GPG: https://gpgtools.org) 

-- 
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/3ABEAB17-6417-4FB6-94BC-6B853FB95176%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] CSRF tokens to not match what is in session (Rails 4.1)

2017-07-26 Thread Jason FB
https://stackoverflow.com/questions/45329731/csrf-tokens-to-not-match-what-is-in-session-rails-4-1


We are seeing an unfortunate and likely browser-based CSRF token 
authenticity problem in our Rails 4.1 app. We are posting it here to ask 
the community if others are seeing it too. 

Please be aware that most error reporting tools — like Honeybadger — 
automatically suppress *ActionController::InvalidAuthenticityToken*, so you 
don't normally see the problem in your error reporting tool unless you go 
out of your way to see it.

Here's the problem, and this is NOT a development issue — it is a 
production issue that has yet to be diagnosed. 

The exception we see is simply ActionController::InvalidAuthenticityToken 
on normal logins to our website. Upon careful examination of the 
*authenticity_token* sent by the form and the session's *_csrf_token* (we 
are using active_record_store as our session_store setting), *they just 
don't match*. Upon direct examination, I can conclude only that they are 
completely different tokens, but I don't know why. 

This is not a simple newbie developer question, please DO NOT answer with 
basic answers about how the CSRF token needs to be passed from the client 
to the server, or how to skip forgery protection on my controllers. I am 
not interested hearing from anyone with either of those two answers: *You 
don't know what you're talking about and you don't understand the depth and 
complexity of the issue.* I am only interested in hearing from people with 
high-traffic websites who have can confirm this is happening on a 
non-insignificant number of visitors (and strangely seems to affect certain 
browsers more often than other browsers.)

We see this problem broadly, maybe about 1-2% of our high traffic website. 
I see it only in Production, I am unable to reproduce it in development 
whatsoever. 

I see it on IE 11 and Edge browsers most (you will note Rails 4.1 was 
released before IE 11 and Edge), but also on Chrome on Android and 
occasionally mobile Safari too.

-- 
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/249c094c-8049-4061-8ba3-b8c38ef1ae1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] cach invalidation help

2017-06-19 Thread Jason Fleetwood-Boldt
Correction: this referenced blog post is from 2012, not 2013




> On Jun 19, 2017, at 10:13 AM, Jason Fleetwood-Boldt  
> wrote:
> 
> 
> Not sure were you got all of this code from… were you following an example 
> somewhere?
> 
> This appears to be way overcomplicated for your use case.
> 
> The definitive and nearly ubiqutious method for simple object caching 
> (incidentally, the singular form is spelled "cache," as in a small hiding 
> place. The word comes from the French, not to be confused with cachet, which 
> also comes from French, and means "superior status" or "prestige") is from 
> the DHH post from 2013…
> 
> https://signalvnoise.com/posts/3113-how-key-based-cache-expiration-works 
> <https://signalvnoise.com/posts/3113-how-key-based-cache-expiration-works>
> 
> 
> Assuming your objects are ActiveResource objects, you automatically get 
> cache_key defined for you.
> 
> All you need to do is wrap the expensive (processing/time-intensive) code in 
> the caching mechanism
> 
> Rails.cache.fetch(@contact)
>// serialize or render the response data
> end 
> 
> 
> … that's it. As explained in DHH's post from 2013, cache_key on @contact 
> automatically includes the timestamp of when the record was last updated. 
> When you make a change to any field the update_at timestamp changes, and so 
> does the cache key, invalidating all caches associated with that cache key.
> 
> All of the other code you have looks like you went down a caching rabbit hole 
> that is unnecessary. (But learning the internals of the Rails caching 
> mechanism is a good thing for your own edification!)
> 
> -Jason 
> 
> 
> 
> 
>> On Jun 18, 2017, at 2:51 AM, Arup Rakshit > <mailto:tuka...@gmail.com>> wrote:
>> 
>> I have the below code:
>> 
>> class ContactsController < ApplicationController
>>  
>>   # ..
>> 
>>   def top_3
>> cache_identifiers = { contact_1: 1, contact_2: 2, contact_3: 3 }
>> cache_keys = cache_identifiers.keys
>> cached_keys_with_values = Rails.cache.read_multi(*cache_keys)
>> uncached_keys = cache_keys.map { |key| key unless 
>> cached_keys_with_values.has_key?(key) }.compact
>> uncached_ids = uncached_keys.map { |key| cache_identifiers[key] }
>> uncached_contacts = Contact.where(id: uncached_ids).to_a
>> 
>> uncached_keys.zip(uncached_contacts).each do |key, value|
>>   Rails.cache.write(key, value)
>> end
>> 
>> @contacts = cache_keys.map do |key|
>>   cached_keys_with_values[key] || uncached_contacts.shift
>> end
>>   end
>> end
>> 
>> I am using memcached as cache store. Now my question is how can I invalidate 
>> the cache when say any of the attributes(name, email) of the contact record 
>> changes.
>> 
>> -- 
>> 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 
>> <mailto:rubyonrails-talk+unsubscr...@googlegroups.com>.
>> To post to this group, send email to rubyonrails-talk@googlegroups.com 
>> <mailto:rubyonrails-talk@googlegroups.com>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/rubyonrails-talk/13256849-6db8-47f9-97e8-c51688d54ba7%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/rubyonrails-talk/13256849-6db8-47f9-97e8-c51688d54ba7%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
> 
> 
> 
> Jason Fleetwood-Boldt
> t...@datatravels.com <mailto:t...@datatravels.com>
> http://www.jasonfleetwoodboldt.com/writing 
> <http://www.jasonfleetwoodboldt.com/writing>
> 
> If you'd like to reply by encrypted email you can find my public key on 
> jasonfleetwoodboldt.com <http://jasonfleetwoodboldt.com/> (more about setting 
> GPG: https://gpgtools.org <https://gpgtools.org/>) 
> 
> 
> -- 
> 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 
> <mailto:rubyonrails-talk+unsubscr...@googlegroups.com>.
> To post to this group, send email to rubyonrails-talk@googlegroups.com 
> <mailto:rubyonrails-talk@googleg

Re: [Rails] browser simulator independent of web framework

2017-06-19 Thread Jason Fleetwood-Boldt


I think he's scraping someone else's site. 

You obviously can't do this with Ruby alone, as there is no headless web 
browser written entirely in Ruby (that's just nonsense)

If you can get phantomjs working on your production site, that's probably the 
way to go. Look deep into the internals of Capybara to understand how it drives 
phantomjs. With phantomjs, you basically have a headless web browser and you 
can use Capybara's DSL to access parts of the page, including evaluating 
scripts and parsing the DOM.

Just keep in mind phantomjs is an actual executable so it needs to be compiled 
and built for your production environment explicitly, which might be a little 
tricky depending on where your site is. 

But a little birdie told me a few months ago that the phantomjs team has 
decided that once Chrome has a headless mode, which I believe is forthcoming, 
they plan to abandon phantomjs in favor of Chrome's headless mode. Not sure if 
that's really true or when that will happen. 

-Jason



> On Jun 18, 2017, at 8:36 AM, Colin Law  wrote:
> 
> On 18 June 2017 at 12:21, Martin Luy  wrote:
>> I'm extracting content from some websites. Currently I evaluate HTML code
>> using Nokogiri. But the relevant content is not contained in the responded
>> body of the HTTP GET request. This is because there is some Javascript code
>> like $(window).load() or $(document).ready() that will send some Ajax
>> requests and fill the original HTML code.
>> 
>> So I'm searching for some library that automatically executes Javascript
>> code and Ajax requests just like a normal browser.
> 
> Understood. Don't think I can help I am afraid. Does the site not work
> with js disabled in the browser?
> 
> Colin
> 
>> 
>> Martin
>> 
>> Von meinem Samsung Gerät gesendet.
>> 
>> 
>>  Ursprüngliche Nachricht 
>> Von: Colin Law 
>> Datum: 18.06.17 09:42 (GMT+01:00)
>> An: "Ruby on Rails: Talk" 
>> Betreff: Re: [Rails] browser simulator independent of web framework
>> 
>> On 17 June 2017 at 22:58, Martin L.  wrote:
>>> Hi all,
>>> 
>>> Is there any browser simulator that fulfills these requirements:
>>> 
>>> - gem written in Ruby
>>> - automatically performing Ajax and Javascript code (XSS is not an issue
>>> in
>>> my case)
>>> - independent of the frameworks used by the website (Rails, JavaEE,
>>> ASP.NET,
>>> ...)
>>> - only client-side
>>> - no testing
>>> - no browser dependency
>> 
>> What do you mean 'no testing'? If not for testing then what is it for?
>> 
>> Colin
>> 
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Ruby on Rails: Talk" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/rubyonrails-talk/H_YImOIzNNo/unsubscribe.
>> To unsubscribe from this group and all its topics, 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%3D0gLvqHArcWpbZ5gsfCiPg0EF%3D4kD8QzZbC3KnicN58uAZ8A%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>> 
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ruby on Rails: Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to rubyonrails-talk+unsubscr...@googlegroups.com.
>> To post to this group, send email to rubyonrails-talk@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/rubyonrails-talk/smyckbsskql3om4h9odf01hm.1497784510166%40email.android.com.
>> 
>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsaS8DzC2o0%3DHkKt_%2BMvvzqutm0mSHUj5jf7CoKvnqJEg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
> 



Jason Fleetwood-Boldt
t...@datatravels.com
http://www.jasonfleetwoodboldt.com/writing

If you&

Re: [Rails] cach invalidation help

2017-06-19 Thread Jason Fleetwood-Boldt

Not sure were you got all of this code from… were you following an example 
somewhere?

This appears to be way overcomplicated for your use case.

The definitive and nearly ubiqutious method for simple object caching 
(incidentally, the singular form is spelled "cache," as in a small hiding 
place. The word comes from the French, not to be confused with cachet, which 
also comes from French, and means "superior status" or "prestige") is from the 
DHH post from 2013…

https://signalvnoise.com/posts/3113-how-key-based-cache-expiration-works


Assuming your objects are ActiveResource objects, you automatically get 
cache_key defined for you.

All you need to do is wrap the expensive (processing/time-intensive) code in 
the caching mechanism

Rails.cache.fetch(@contact)
   // serialize or render the response data
end 


… that's it. As explained in DHH's post from 2013, cache_key on @contact 
automatically includes the timestamp of when the record was last updated. When 
you make a change to any field the update_at timestamp changes, and so does the 
cache key, invalidating all caches associated with that cache key.

All of the other code you have looks like you went down a caching rabbit hole 
that is unnecessary. (But learning the internals of the Rails caching mechanism 
is a good thing for your own edification!)

-Jason 




> On Jun 18, 2017, at 2:51 AM, Arup Rakshit  wrote:
> 
> I have the below code:
> 
> class ContactsController < ApplicationController
>  
>   # ..
> 
>   def top_3
> cache_identifiers = { contact_1: 1, contact_2: 2, contact_3: 3 }
> cache_keys = cache_identifiers.keys
> cached_keys_with_values = Rails.cache.read_multi(*cache_keys)
> uncached_keys = cache_keys.map { |key| key unless 
> cached_keys_with_values.has_key?(key) }.compact
> uncached_ids = uncached_keys.map { |key| cache_identifiers[key] }
> uncached_contacts = Contact.where(id: uncached_ids).to_a
> 
> uncached_keys.zip(uncached_contacts).each do |key, value|
>   Rails.cache.write(key, value)
> end
> 
> @contacts = cache_keys.map do |key|
>   cached_keys_with_values[key] || uncached_contacts.shift
> end
>   end
> end
> 
> I am using memcached as cache store. Now my question is how can I invalidate 
> the cache when say any of the attributes(name, email) of the contact record 
> changes.
> 
> -- 
> 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 
> <mailto:rubyonrails-talk+unsubscr...@googlegroups.com>.
> To post to this group, send email to rubyonrails-talk@googlegroups.com 
> <mailto:rubyonrails-talk@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/13256849-6db8-47f9-97e8-c51688d54ba7%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/rubyonrails-talk/13256849-6db8-47f9-97e8-c51688d54ba7%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.



Jason Fleetwood-Boldt
t...@datatravels.com
http://www.jasonfleetwoodboldt.com/writing

If you'd like to reply by encrypted email you can find my public key on 
jasonfleetwoodboldt.com <http://jasonfleetwoodboldt.com/> (more about setting 
GPG: https://gpgtools.org) 

-- 
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/6BC11AD8-3FCA-418B-A0D5-9EBD3438CE5F%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] jquery logic

2017-06-16 Thread Jason Fleetwood-Boldt
Generally very large and apps built after 2013 have moved on to frameworks like 
Backbone, React, Ember, etc. 

For a simple or prototype app, RJS is totally appropriate. And as a beginning 
developer it's totally a great idea to learn how jQuery and Turbolinks works. 

On a larger app, coding like that you will wind up with "jQuery soup" which in 
my experience never really works out to build a maintainable codebase. 

Rails doesn't really have a robust "javascript solution" other than RJS, taking 
the agnostic stance that it is a back-end technology. Having said that, the 
latest version of Rails had a strongly-worded stake in the sand 
<http://weblog.rubyonrails.org/2017/4/27/Rails-5-1-final/> statement about 
Rails & the future of Javascript, in which a package manager (Yarn) was made 
the default. 

But even with Rails moving in that direction, it still means if you want to 
build a large, robust front-end app you'll probably be picking a JS framework 
or writing a bare-bones one yourself (or using a bare-bones one, like Backbone, 
which is what I prefer.)

What you are doing with RJS/UJS is the way to go for your purposes for a small 
app. 

-Jason




> On Jun 15, 2017, at 10:45 PM, fugee ohu  wrote:
> 
> Thanks Is this what everyone else is doing ? 



Jason Fleetwood-Boldt
t...@datatravels.com
http://www.jasonfleetwoodboldt.com/writing

If you'd like to reply by encrypted email you can find my public key on 
jasonfleetwoodboldt.com <http://jasonfleetwoodboldt.com/> (more about setting 
GPG: https://gpgtools.org) 

-- 
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/9D0C6D0C-FB8E-48A2-BCC4-BE8D99CCFBB9%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] rubymine 2.4.1

2017-06-07 Thread Jason Fleetwood-Boldt
http://www.jasonfleetwoodboldt.com/writing/2014/10/14/how-to-install-an-older-version-of-rails/



> On Jun 6, 2017, at 7:40 PM, Joe Guerra  wrote:
> 
> Lol, now I've got to get rails installed for that version.  
> 
> My default version is still 2.3.1.



Jason Fleetwood-Boldt
t...@datatravels.com
http://www.jasonfleetwoodboldt.com/writing

If you'd like to reply by encrypted email you can find my public key on 
jasonfleetwoodboldt.com <http://jasonfleetwoodboldt.com/> (more about setting 
GPG: https://gpgtools.org) 

-- 
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/13996905-D933-4FC9-AB46-507232660CC0%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] http requests

2017-06-06 Thread Jason Fleetwood-Boldt
Joe -


This (gems having gone stale) is generally par for the course in the Ruby world.

This is a good resource that gives you some idea of how popular & active any 
given gem might be:

https://www.ruby-toolbox.com

Choosing an old gem that is stale (hasn't been updated in a couple of years) is 
common. Then again, the team I work with did an exhaustive internet search for 
some gem code that had to do with image optimization. They told me that one or 
more of the gems they were looking at hadn't been updated since 2015. We all 
laughed and thought to ourselves that meant it was a stale codebase.

Then upon more digging, we realized that the code from 2015 actually worked 
fine, and we just hadn't spent enough time trying to make it work for us. So in 
that case, it wasn't that no one had worked on image optimization since 2015, 
it was because that problem was solved in 2015 (in that example), and didn't 
need more work because it continued to work in 2017. 


As far as Canada Post, we use EasyPost for our shipping labels 
(https://www.easypost.com), which is NOT a gem, but in fact a SAS service. (It, 
incidentally, does have an open-source gem that has the API for communicating 
with EasyPost. But you pay them a small fee to generate each label).


Before you email the author of the gem, I'd like to take a small moment to 
expound on the nature of open-source software:

They said this back in the 90s, but it's so important and so relevant to you 
I'm gonna say it again:

"Free as in speech, not free as in beer."


"Free software" (what we called open source back in the 90s) isn't "free" like 
you don't have to pay for it. If that's what you think, you are totally wrong 
and need to adjust your mindset. It is "free as in speech" — can be copied, 
modified, etc, without limits imposed on it. 

So consider that someone — two years ago — wrote some code to interface with 
Canada Post. They put their code on Github. Putting OS code on Github has no 
guarantee that that author is going to continue to maintain it. 

And take a step back and think about this: Why would they? You have a need to 
have Ruby code that works with Canada Post. Maybe they do too, or maybe they 
have moved on an work somewhere else now, or maybe they won the lottery and 
retired, or maybe they got sick of being a Ruby developer and got a new 
profession. Or maybe (heavens to betsy!) they switched to Node.JS.

It's kind of like Ray Bradbury's great The Martian Chronicles: Someone was here 
once, they left some artifacts, you get to enjoy those artifacts, but you don't 
get to be them or live in their (ancient, bygone) society. (Ok so that Martian 
Chronicles analogy was a stretch. I'll work on it. But that is actually the 
core thesis of the Martian Chronicles — one of the best books of all time.)

My point is that unless you are offering to pay him or her, you need to think 
about the implicit need-dynamics of emailing him to "get his take on it." 
Obviously, there's nothing wrong with that on the face of it. But "free 
software" isn't "free" like you don't have to pay for it ("free as in beer"), 
it's "free" like the 1st amendment of the US Constitution (sorry Canadians!), 
there can be no laws recognized that limit it ("free speech").

This is a crucial and important concept to understand as you navigate the world 
of old gems that are no longer usable.

Oh and since you're new to the community: Check out that "Fork" button on 
Github! 

Fork the Gem, fix it, and submit your changes back to the original repository — 
you will then be contributing to the whole community. If you think the author 
is gone (like the martians in the Martian Chronicles), dead (that happens too— 
in fact I've corresponded with Github tech support over their policy regarding 
passed-away authors), or no longer cares, you can detach your fork from the 
origin repository and make a "V2" (or whatever) of the gem, upgraded with your 
fixes, rename it, and then you'll be the Gem's author. 

Then in 2 years from now when Canada Post changes their API again, some 
aspiring Ruby code will email YOU and say "why doesn't this gem work"! 
-Jason







> On Jun 6, 2017, at 4:20 PM, Joe Guerra  wrote:
> 
> Yes, I'm going to email the author of the gem.  Get his take on it. 
> It hasn't been updated for over 2 years.  Maybe something has changed on the 
> Canada post side.



Jason Fleetwood-Boldt
t...@datatravels.com
http://www.jasonfleetwoodboldt.com/writing

If you'd like to reply by encrypted email you can find my public key on 
jasonfleetwoodboldt.com <http://jasonfleetwoodboldt.com/> (more about setting 
GPG: https://gpgtools.org) 

-- 
You received this message bec

Re: [Rails] passing params to controller redirects

2017-06-06 Thread Jason Fleetwood-Boldt
Did you try it without specifying the params?

Last I checked if you define a redirect(…) in your routes.rb file, the query 
params are automatically passed along to the redirected page. 

(*I'm on an older version of Rails, so if this changed in Rails recently then 
ask someone who has experience with more recent versions of Rails)


If that doesn't work maybe try

  get '/xyz', to: redirect {|path_params, req| "/abc#{'?' if req.params.any?}" 
+ req.params.to_query}





> On Jun 5, 2017, at 11:53 PM, fugee ohu  wrote:
> 
> my index action is looking for params[:club][:genre_id]
> after a club is successfully added or updated i wanna pass those (nested) 
> params back to my index action so my filter will be set to the right genre_id 
> but clubs_path(:genre_id => @genre_id) after setting @genre_id = 
> params[:club][:genre_id] doesn't work the index page loads without a genre_id 
> set
> 
> -- 
> 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 
> <mailto:rubyonrails-talk+unsubscr...@googlegroups.com>.
> To post to this group, send email to rubyonrails-talk@googlegroups.com 
> <mailto:rubyonrails-talk@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/8dc82eee-1301-4fbc-818b-2bd57984c8dc%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/rubyonrails-talk/8dc82eee-1301-4fbc-818b-2bd57984c8dc%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.



Jason Fleetwood-Boldt
t...@datatravels.com
http://www.jasonfleetwoodboldt.com/writing

If you'd like to reply by encrypted email you can find my public key on 
jasonfleetwoodboldt.com <http://jasonfleetwoodboldt.com/> (more about setting 
GPG: https://gpgtools.org) 

-- 
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/2109DD4C-8F8A-4714-B987-1B5A83B5F80B%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] How do I make JSON api calls?

2017-06-05 Thread Jason Fleetwood-Boldt

See Net::HTTP.

I would send you a link but ruby-doc.org is down

You do not need a model, in fact you probably shouldn't have one unless you 
want to store the data you receive somewhere. (even then you don't need a model)

You should think outside of the MVC box. Just because DHH put 3 folders named 
"models", "views", and "controllers" doesn't mean you have to put all of your 
ruby code there, especially if MVC doesn't fit your needs.


One specific scalability thing you might consider is that a in-request 
server-to-server API is generally considered non-scalable, but it depends on 
the response time on the remote API. If it is very fast maybe it will work. If 
it is slow, it will slow down your website.

If I'd were to build something really scalable, I'd fetch the external data in 
a background process and store it — database or otherwise — so that when the 
user looks at it it comes from cached place (may be a few minute stale). Then a 
background job runs on an as-needed basis to keep the data fresh. That's the 
scalable way to do it. 

But if scalability isn't a concern you can just make the API call, format the 
data the way you want it, and show it to the user. 

Your question was very high level and so was this answer. As a more 
specific/detailed question if you want a more specific/detailed answer. Your 
mileage may vary. 

-Jason

> On Jun 5, 2017, at 11:56 AM, Charlie Lor  wrote:
> 
> I'm very new to ruby on rails. I need a view that will show the data from a 
> JSON API calls. How do accomplish this? Do I need to create a model for this? 
> I assumed the controller is the place to put my API calls code, correct?
> 
> -- 
> 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 
> <mailto:rubyonrails-talk+unsubscr...@googlegroups.com>.
> To post to this group, send email to rubyonrails-talk@googlegroups.com 
> <mailto:rubyonrails-talk@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/98a65791-de22-4d63-ac39-a40d035cfdeb%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/rubyonrails-talk/98a65791-de22-4d63-ac39-a40d035cfdeb%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.



Jason Fleetwood-Boldt
t...@datatravels.com
http://www.jasonfleetwoodboldt.com/writing

If you'd like to reply by encrypted email you can find my public key on 
jasonfleetwoodboldt.com <http://jasonfleetwoodboldt.com/> (more about setting 
GPG: https://gpgtools.org) 

-- 
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/805D4E44-E2D3-4CA4-A7EC-23F7C7FE5A94%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] http requests

2017-05-31 Thread Jason Fleetwood-Boldt
Hassan is correctly encouraging you towards the higher-level abstractions, like 
a Gem specifically written for this purpose.

If you really want to know how to make outgoing http requests, the answer is 
the Net::HTTP Ruby library, which is documented here:

https://docs.ruby-lang.org/en/2.0.0/Net/HTTP.html

But as Hassan said if there's a higher level abstraction, like a Gem, prefer 
that to writing your own low-level code.

But as a ruby developer the Net::HTTP Ruby library is at the very least 
something you should learn about and play around with, even if you don't 
actually need it for this immediate purpose.
-Jason



> On May 31, 2017, at 1:39 PM, Joe Guerra  wrote:
> 
> Ok, I'll try the gem.
> 
> How about passing the parameters in the url?  and opening up the canada post 
> site with that?
> 
> Thanks,
> Joe
> 
> On Wednesday, May 31, 2017 at 1:36:20 PM UTC-4, Hassan Schroeder wrote:
> On Wed, May 31, 2017 at 10:27 AM, Joe Guerra  > wrote: 
> > Hmm, which gem would allow you to perform http requests within Rails?  I 
> > would like to send a request to the canadapost website and pass it some 
> > parameters and return a shipping total. 
> > 
> > I do believe there is a canadapost gem, but I'm not sure how upto date it 
> > is. 
> 
> Searching for `ruby gem canada post` turns up more than one -- why 
> don't you just try them and see which you prefer? 
> 
> Similarly `ruby gem http` will show you some possibilities if you want 
> to roll your own solution. See also: 
> https://ruby-doc.org/stdlib-2.4.1/libdoc/net/http/rdoc/index.html 
> <https://ruby-doc.org/stdlib-2.4.1/libdoc/net/http/rdoc/index.html> 
> 
> HTH! 
> -- 
> Hassan Schroeder  hassan.s...@gmail.com  
> twitter: @hassan 
> Consulting Availability : Silicon Valley or remote 
> 
> -- 
> 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 
> <mailto:rubyonrails-talk+unsubscr...@googlegroups.com>.
> To post to this group, send email to rubyonrails-talk@googlegroups.com 
> <mailto:rubyonrails-talk@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/80f27a88-f7ca-4bc8-a66c-380da41a4ccf%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/rubyonrails-talk/80f27a88-f7ca-4bc8-a66c-380da41a4ccf%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.



Jason Fleetwood-Boldt
t...@datatravels.com
http://www.jasonfleetwoodboldt.com/writing

If you'd like to reply by encrypted email you can find my public key on 
jasonfleetwoodboldt.com <http://jasonfleetwoodboldt.com/> (more about setting 
GPG: https://gpgtools.org) 

-- 
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/40BBA1BD-B10F-4D38-8C58-534574700D75%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] sql select rolls back trying to figure out why

2017-05-05 Thread Jason Fleetwood-Boldt

> On May 4, 2017, at 6:02 PM, fugee ohu  wrote:
> 
> Debug helpers/statements go in views or controllers or can  be used in either?



You can generally use debuggers anywhere in Ruby code. (most of the community 
prefers byebug I think, but I can't speak for everyone. I know some who still 
use pry).

In your views, sometimes I stick a debugging statement in just inside the 
markup, like so (assuming your view is ERB):

<% byebug %>


The only exceptions to that might be a cached partial, which won't get 
re-evaluated. To work around such a problem, remove the caching or clear the 
Rails cache. 

-Jason




Jason Fleetwood-Boldt
t...@datatravels.com
http://www.jasonfleetwoodboldt.com/writing

If you'd like to reply by encrypted email you can find my public key on 
jasonfleetwoodboldt.com <http://jasonfleetwoodboldt.com/> (more about setting 
GPG: https://gpgtools.org) 

-- 
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/197B6328-9F54-4577-BE7D-17C24B46B1C7%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] sql select rolls back trying to figure out why

2017-05-04 Thread Jason Fleetwood-Boldt
 

No, no, fugee...@gmail.com, you'll need to debug your own app yourself.

>From the log entries you sent, I can see that you did not follow my explicit 
>advice to set the lines setting to more than 5. 

You'll want to set the lines setting to show you the entire stacktrace, because 
with 5 lines only you only will see the Rails gem code, not your own code. 
You'l want at least as many lines of stacktrace as it takes to get to your own 
app's code.

Then you'll need to put a debugger (pry or byebug) just before the line of code 
that corresponds to the rollback. 

Then you'll want to step through your code line-by-line to figure out what is 
causing the exception. 

Since the rest of us on this list do not have access to your app's code, it is 
impossible for us to debug it for you. We are only trying to point you in the 
right direction to empower you to use the best tools and troubleshooting 
methods to set yourself up for success.

If you have specific questions about tools or methodology regarding debugging, 
I think people on this list will help you out. But sending stacktraces without 
explaining where you are stuck is probably not going to get you where you need 
to be.

Best of luck!
-Jason




> On May 4, 2017, at 12:25 PM, fugee ohu  wrote:
> 
> 
> 
> On Thursday, May 4, 2017 at 12:00:06 PM UTC-4, Jason FB wrote:
> Try ActiveRecord Query Trace
> 
> see...
> 
> https://github.com/ruckus/active-record-query-trace 
> <https://github.com/ruckus/active-record-query-trace>
> 
> 
> I would suggest setting the level to :full or :rails like so, in case the bug 
> comes from a Gem or Rails itself. 
> 
> 
> ActiveRecordQueryTrace.level = :full
> 
> or 
> 
> ActiveRecordQueryTrace.level = :rails
> (which is NOT the default)
> 
> 
> Also try adjusting the lines setting to something that will show you the full 
> trace, sometimes 25 or 100 or even 200 if your stack level is very deep. (But 
> with 200 line stacktrace, it makes it harder to read, so you have to find the 
> right balance)
> 
> You are looking for a ruby crash within the transaction itself, which would 
> then cause the transaction to be rolled back. 
> 
> -Jason
> 
> 
> 
> 
> 
>> On May 3, 2017, at 11:35 PM, fugee ohu > 
>> wrote:
>> 
>> 
>> 
>> On Wednesday, May 3, 2017 at 9:44:06 PM UTC-4, Walter Lee Davis wrote:
>> 
>> > On May 3, 2017, at 9:07 PM, fugee ohu > wrote: 
>> > 
>> > 
>> > 
>> > On Wednesday, May 3, 2017 at 8:04:29 PM UTC-4, Edsil Basadre wrote: 
>> > Sorry! Your question is quite vague. What did you do? You manually run a 
>> > select query but then it rollback or you did a request in which it runs 
>> > the select query then it rollback? please make the question more clear and 
>> > if you can provide more error details. 
>> > 
>> > On Thu, 4 May 2017 at 7:37 AM, fugue ohu > wrote: 
>> > When I run the select that rolls back in mysql there's no problem How can 
>> > I debug this? 
>> > 
>> > Started POST "/artist/14/tour/3/press_releases/new" for 127.0.0.1 at 
>> > 2017-05-03 19:08:27 -0400 
>> > Processing by UserPressReleasesController#tour_create as HTML 
>> >   Parameters: 
>> > {"authenticity_token"=>"J/ZFBljt2V9q+yEV78t+L9BOjEkqpWHyFx29HSPdB0+/PKX7s4bxLhzcoP4mtepmoKJ2NY4JKCIOcfhJBQAMXg==",
>> >  "artist_id"=>"14", "tour_id"=>"3"} 
>> >   [1m [36mUser Load (2.0ms) [0m  [1m [34mSELECT  `users`.* FROM `users` 
>> > WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m 
>> >   [1m [36mArtist Load (1.9ms) [0m  [1m [34mSELECT  `artists`.* FROM 
>> > `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m 
>> >   [1m [36mTour Load (1.4ms) [0m  [1m [34mSELECT  `tours`.* FROM `tours` 
>> > WHERE `tours`.`id` = 3 LIMIT 1 [0m 
>> >   [1m [35m (0.6ms) [0m  [1m [35mBEGIN [0m 
>> >   [1m [35m (3.0ms) [0m  [1m [31mROLLBACK [0m 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google Groups 
>> > "Ruby on Rails: Talk" group. 
>> > To unsubscribe from this group and stop receiving emails from it, send an 
>> > email to rubyonrails-ta...@googlegroups.com <>. 
>> > To post to this group, send email to rubyonra...@googlegroups.com <>. 
>> > To view this discussion on the web visit 
>> > https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com
>> >  
>> > <https://groups.google.com/d/msgid/rubyo

Re: [Rails] sql select rolls back trying to figure out why

2017-05-04 Thread Jason Fleetwood-Boldt
Try ActiveRecord Query Trace

see...

https://github.com/ruckus/active-record-query-trace


I would suggest setting the level to :full or :rails like so, in case the bug 
comes from a Gem or Rails itself. 


ActiveRecordQueryTrace.level = :full

or 

ActiveRecordQueryTrace.level = :rails
(which is NOT the default)


Also try adjusting the lines setting to something that will show you the full 
trace, sometimes 25 or 100 or even 200 if your stack level is very deep. (But 
with 200 line stacktrace, it makes it harder to read, so you have to find the 
right balance)

You are looking for a ruby crash within the transaction itself, which would 
then cause the transaction to be rolled back. 

-Jason





> On May 3, 2017, at 11:35 PM, fugee ohu  wrote:
> 
> 
> 
> On Wednesday, May 3, 2017 at 9:44:06 PM UTC-4, Walter Lee Davis wrote:
> 
> > On May 3, 2017, at 9:07 PM, fugee ohu > 
> > wrote: 
> > 
> > 
> > 
> > On Wednesday, May 3, 2017 at 8:04:29 PM UTC-4, Edsil Basadre wrote: 
> > Sorry! Your question is quite vague. What did you do? You manually run a 
> > select query but then it rollback or you did a request in which it runs the 
> > select query then it rollback? please make the question more clear and if 
> > you can provide more error details. 
> > 
> > On Thu, 4 May 2017 at 7:37 AM, fugue ohu > wrote: 
> > When I run the select that rolls back in mysql there's no problem How can I 
> > debug this? 
> > 
> > Started POST "/artist/14/tour/3/press_releases/new" for 127.0.0.1 at 
> > 2017-05-03 19:08:27 -0400 
> > Processing by UserPressReleasesController#tour_create as HTML 
> >   Parameters: 
> > {"authenticity_token"=>"J/ZFBljt2V9q+yEV78t+L9BOjEkqpWHyFx29HSPdB0+/PKX7s4bxLhzcoP4mtepmoKJ2NY4JKCIOcfhJBQAMXg==",
> >  "artist_id"=>"14", "tour_id"=>"3"} 
> >   [1m [36mUser Load (2.0ms) [0m  [1m [34mSELECT  `users`.* FROM `users` 
> > WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1 [0m 
> >   [1m [36mArtist Load (1.9ms) [0m  [1m [34mSELECT  `artists`.* FROM 
> > `artists` WHERE `artists`.`id` = 14 LIMIT 1 [0m 
> >   [1m [36mTour Load (1.4ms) [0m  [1m [34mSELECT  `tours`.* FROM `tours` 
> > WHERE `tours`.`id` = 3 LIMIT 1 [0m 
> >   [1m [35m (0.6ms) [0m  [1m [35mBEGIN [0m 
> >   [1m [35m (3.0ms) [0m  [1m [31mROLLBACK [0m 
> > 
> > -- 
> > You received this message because you are subscribed to the Google Groups 
> > "Ruby on Rails: Talk" group. 
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to rubyonrails-ta...@googlegroups.com <>. 
> > To post to this group, send email to rubyonra...@googlegroups.com <>. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com
> >  
> > <https://groups.google.com/d/msgid/rubyonrails-talk/0d6c0119-f666-4d8f-9ece-d2476e36dfe6%40googlegroups.com>.
> >  
> > For more options, visit https://groups.google.com/d/opto 
> > <https://groups.google.com/d/opto> 
> > 
> > As you can see the log begins with a post request and you can see the 
> > params list Of course there's an associated controller action but I don't 
> > know why the rollback 
> > 
> 
> I am not clear why you are using POST to load a /new path. Those are usually 
> done with GET. You would POST from that form to the collection (the create 
> verb), and after that, you would GET the form for the persisted object and 
> PATCH to it to update it. I would expect this action (creating a press 
> release for artist 14 and tour 3) to look like this: POST 
> /artist/14/tours/3/press_releases. It would hit the 
> press_releases_controller.rb on the #create verb (never the #new). The fact 
> that the method is #tour_create is surprising, since you already have a tour 
> persisted (id 4). Any further things you might do to that tour would update 
> it, and would go through the tours_controller.rb, hitting the #update method, 
> not the press_releases_controller. 
> 
> I'm scared to ask, but what does your routes.rb file look like? 
> 
> Without changing anything else right now, inside your mis-named tour_create 
> method, add a line that looks like this, after any line that includes 
> @press_release.save 
> 
> Rails.logger.info <http://rails.logger.info/> 
> @press_release.errors.inspect 
> 
> That should give you a concise block of output, which may end in the human 
> readable errors on that object in a hash syntax. See what that looks like, 
> and if it gives 

Re: [Rails] conditional validatiobs

2017-03-29 Thread Jason Knabl
Use the `unless` key instead of `if` on the validation.

This will perform the validation unless the column is null, i.e., will
perform validation if the column is not null.

http://guides.rubyonrails.org/active_record_validations.html#conditional-validation

-Jason

On Mar 29, 2017 8:35 AM, "fugee ohu"  wrote:

Trying to validate presence where another field is not null
I found this example, the opposite

class Person < ApplicationRecord
  validates :surname, presence: true, if: "name.nil?"
end

How do I change the if: condition to name not nil?

-- 
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/7af99734-ca1f-41d0-9252-7deaad800783%40googlegroups.
com
<https://groups.google.com/d/msgid/rubyonrails-talk/7af99734-ca1f-41d0-9252-7deaad800783%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.

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


[Rails] Re: Using Mailgun in Heroku

2017-02-09 Thread Jason Hsu, Ruby on High Speed Rails
When I enter "heroku logs", the error message I get is:
Net::SMTPFatalError (554 Sandbox subdomains are for test purposes only. 
Please add your own domain or add the 
address to authorized recipients in Account Settings.

-- 
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/47130358-0cd3-43b8-bae1-73b6abd13b65%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Using Mailgun in Heroku

2017-02-09 Thread Jason Hsu, Ruby on High Speed Rails
How do you use Mailgun in the Heroku production environment for 
transactional emails?

I've already successfully implemented SendGrid for transactional emails.  
I've written up the whole procedure at 
https://gist.github.com/jhsu802701/a7ac8d4ccdc5d993a61a9de293f104df .

What's the proper procedure for using Mailgun?  There's something missing 
from Heroku's procedure.  I've tried changing the 
config/environments/production.rb file, but the production email still 
doesn't work.  The project in question is at 
https://github.com/jhsu802701/tmp-heroku-2017-02-09-1833 .

-- 
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/4c7bcf4b-8ef1-4487-98ac-d8484082288a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Trouble with downloading Ruby

2017-01-27 Thread Jason Hsu, Ruby on High Speed Rails
Use Docker.  Go to my web site Ruby on Racetracks at 
http://www.rubyonracetracks.com/, click on Installation, and click on 
"Getting Started".  You can have Ruby on Rails ready to roll in minutes, 
not hours.  You can also reset the Docker container to its original 
conditions in just a few seconds.

I make sure that my rbenv-general Docker images include the latest versions 
of Ruby and Rails and the versions currently used in Rails Tutorial.

In my opinion, the main reason for having Ruby on Rails directly in the 
host OS is to be on the same page as teammates who rely on this setup.  
Because it takes hours of babysitting processes to set this up and because 
you can't reset this development environment willy-nilly (as you can under 
the Docker way), I will NOT rely on Ruby on Rails in the host OS as my 
primary setup.

-- 
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/6d6c2341-45c0-40f3-b458-e1afa748f77b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Rails From Scratch and Generic App version 2

2017-01-27 Thread Jason Hsu, Ruby on High Speed Rails


Check out Version 2 of my gem GenericApp 
https://github.com/jhsu802701/generic_app) for creating a new Rails app. No 
other Rails template app is this comprehensive.


I created the template app used as the basis for GenericApp with my Rails 
>From Scratch protocol 
athttps://github.com/jhsu802701/rails_from_scratch_rails5 . Rails From 
Scratch was inspired by Rails Tutorial but has much shorter chapters, uses 
the Devise gem to provide authentication, uses Capybara for integration 
tests, and provides scripts for automating many routine tasks.  Rails From 
Scratch also doubles as a cheat sheet for possible features to add to 
legacy projects and for many routine tasks.

-- 
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/8380aa64-ea84-4eb4-bd5a-8c400deeb538%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Your procedure for starting a new Ruby on Rails app

2016-10-22 Thread Jason Hsu, Ruby on High Speed Rails
I'm currently working on a procedure for starting a new Ruby on Rails app. 
 The URL is https://github.com/jhsu802701/rails_from_scratch_rails5 .  The 
idea is to be able to create a HIGH-QUALITY starter app with authentication 
and comprehensive tests completely from scratch in just a few hours.  I'll 
be using this procedure to create starter apps for my GenericApp gem so 
that I can start new, high-quality, and up-to-date apps willy-nilly.  (Good 
luck getting anywhere at Startup Weekend or a 24-hour web site challenge 
when you need precious hours just to get the basics up and running.)  It 
also doubles as a giant cheat sheet of how to do many routine tasks and add 
many routine features to legacy apps.  Yes, I find this 100% necessary, 
because I don't have a photographic memory.  I HATE having to struggle with 
something that I already did before simply because I don't have every 
detail memorized.

Michael Hartl's Rails Tutorial inspired me.  I like what he did, but I 
disagree with some of the ways he does things.  (My biggest disagreement is 
with his large steps.  I break the process down into many small steps so 
that I don't lose track of what I'm doing and to make sure that I can 
quickly resolve any setbacks I encounter.)

When you start a new Ruby on Rails app with the "rails new" command, what's 
your procedure?  Are there any procedures out there that are similar to or 
better than Rails Tutorial?  I just cannot imagine how you can get anything 
done in a reasonable amount of time without a procedure spelled out.  I'm 
surprised that there aren't already hundreds or thousands of different 
procedures like mine out there.

-- 
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/34509bd7-57be-4eeb-8f3d-19d76efdadf5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] App passes all test in development but fails in Travis

2016-09-09 Thread Jason Hsu, Ruby on High Speed Rails
My Rails app consistently passes all tests in the development environment, 
but my Travis builds keep failing. The source code is at 
https://github.com/jhsu802701/generic_app_template_rails5/tree/travis .

The test results are at 
https://travis-ci.org/jhsu802701/generic_app_template_rails5

The parts of the code that fail in Travis are:
1. app/views/static_pages/home.html.erb: link_to image_tag at end; 
ActionView::Template::Error: wrong number of arguments (given 1, expected 0)
2. app/views/layouts/application.html.erb: <%= stylesheet_link_tag 
'application', media: 'all', 'data-turbolinks-track': 'reload' %>; 
ActionView::Template::Error: wrong number of arguments (given 1, expected 0)

I thought that not having Node installed in Travis was the problem. I 
finally was able to get Node installed in Travis, but that didn't resolve 
the problem.

-- 
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/a7578985-cdeb-481d-b817-257d072c69cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Passing parameters to JS

2016-07-19 Thread Jason Hou
Share a gem https://github.com/falm/js-namespace-rails that can execute
page-specific javascript and passing parameters from controller to
assets js fiel

-- 
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/36d82a0c915ef3b30fd5367fb9cd883a%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Codeclimate test coverage: dinged for config/initializers/rack_profiler.rb

2016-03-28 Thread Jason Hsu, Ruby on High Speed Rails
It's easier to see changes when I'm at 100%.  What I'm trying to do is 
analogous to configuring Rubocop and Rails Best Practices to ignore certain 
violations.  (Given how nitpicky these tools can be, some violations may 
not be worth correcting.)

On Sunday, March 27, 2016 at 12:46:51 AM UTC-5, tamouse wrote:
>
>
> You've just slipped off the edge of using metrics to meaningfully improve 
> your testing to gaming the metric collection to meaninglessly improve a 
> metric.
>
>

-- 
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/28ed3881-5ff5-4204-9ecf-5edae4e42b7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Codeclimate test coverage: dinged for config/initializers/rack_profiler.rb

2016-03-26 Thread Jason Hsu, Ruby on High Speed Rails
My project at https://github.com/jhsu802701/losemoneyfast is rated at 98.7% 
test coverage.  I'm getting dinged for config/initializers/rack_profiler.rb 
.

Is there something I can do to fix this or to get the CodeClimate engine to 
skip this file in its test coverage analysis?

-- 
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/1c95775c-4aab-4d83-8a2e-d07c1637609a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Ruby on Racetracks

2016-03-25 Thread Jason Hsu, Ruby on High Speed Rails
Check out my new web site Ruby on Racetracks at 
http://www.rubyonracetracks.com . On this site, I have described the use of 
tools like Docker, GenericGem, and GenericApp for getting more done in less 
time while improving quality. If you find the conventional procedures to be 
too time-consuming and error-prone, then this is the site for you.

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


[Rails] Integration tests involving Javascript dialog boxes

2016-02-04 Thread Jason Hsu, Ruby on High Speed Rails
I'm working on an integration test for a project that uses minitest and 
Capybara.  You can find the source code in question at 
https://github.com/jhsu802701/ruby_mn_site/blob/sponsors_delete/test/integration/sponsors_change_test.rb
 in 
the section 'super admin can add, change, or delete sponsors'.

When you click on the Delete button, there's a Javascript dialog box that 
asks if you're sure and gives you the "Cancel" or "OK" options.  How do I 
get the test to click the "OK" option given that the normal 
Capybara/minitest commands only work on the HTML page and do not work on 
these pop-up dialog boxes?

-- 
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/a83187fd-f66f-47f3-b99c-2ea46bf81a84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Re: Why is admin_signed_in? false even after logging in as admin?

2015-12-11 Thread Jason Hsu, Ruby on High Speed Rails
Thanks.  Yes, this was the problem.  Now I understand that this is the 
proper procedure for logging in for functional tests.

This raises another question: Given my use of if statements in my def 
create function, is there any point to using before_filter or before_action 
in the controller?  The before_filter/before_action statement doesn't 
replace the need for those if statements.

On Friday, December 11, 2015 at 12:44:41 PM UTC-6, Rob Biedenharn wrote:
>
>
> > On 2015-Dec-11, at 13:12 , Jason Hsu, Ruby on High Speed Rails <
> jhsu8...@gmail.com > wrote: 
> > 
> > The admin_signed_in? method comes from the Devise gem. 
>
> Are you using the :admin scope to do the login? 
>
> I.e., somewhere in your login_as helper there should be something like? 
>
> sign_in :admin, some_user_who_is_admin 
>
>
> -Rob

-- 
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/5c47366b-2641-469b-a5de-4981e95e2fcf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Why is admin_signed_in? false even after logging in as admin?

2015-12-11 Thread Jason Hsu, Ruby on High Speed Rails
The admin_signed_in? method comes from the Devise gem.

-- 
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/30d7124e-5de0-49c8-a9f8-859c71a360fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Why is admin_signed_in? false even after logging in as admin?

2015-12-11 Thread Jason Hsu, Ruby on High Speed Rails
Back story:
I'm developing a new Rails site for the local Ruby user group.  I'm using 
Devise to provide authentication for separate user and admin classes.

Current task:
I'm working on the create/new function for the sponsor class.  Sponsors are 
an independent class and are not tied to users, admins, or other classes. 
 However, only admins should be allowed to create sponsors.

The problem:
In my sponsor controller tests, I'm unable to prevent users and 
unauthenticated visitors from creating new sponsors without also preventing 
admins from doing so.  Troubleshooting with the puts command reveals that 
the admin_signed_in? value is false EVEN AFTER loggin in.

The source code of this app is 
at https://github.com/jhsu802701/ruby_mn_site/tree/sponsors_create_controller 
.

Excerpt from test/controllers/sponsors_controller_test.rb:

  test 'superadmin can create a new sponsor' do
login_as @a1

assert_difference 'Sponsor.count', 1 do
  add_past
end

assert_difference 'Sponsor.count', 1 do
  add_current
end

logout :admin
  end

  test 'regular admin can create a new sponsor' do
login_as @a3

assert_difference 'Sponsor.count', 1 do
  add_past
end

assert_difference 'Sponsor.count', 1 do
  add_current
end

logout :admin
  end

  test 'user cannot create a new sponsor' do
login_as @u1

assert_no_difference 'Sponsor.count' do
  add_past
end

assert_no_difference 'Sponsor.count' do
  add_current
end

logout :user
  end

  test 'an unregistered visitor cannot create a new sponsor' do
assert_no_difference 'Sponsor.count' do
  add_past
end

assert_no_difference 'Sponsor.count' do
  add_current
end
  end


app/controllers/sponsors_controller.rb

#
class SponsorsController < ApplicationController
  before_filter :admin_signed_in?, except: [:index, :show]

  def index
@sponsors_current = Sponsor.where('current=?', true)
@sponsors_past = Sponsor.where('current!=?', true)
  end

  def show
@sponsor = Sponsor.find(params[:id])
  end

  def new
@sponsor = Sponsor.new
  end

  def create
puts admin_signed_in?
if admin_signed_in?
  @sponsor = Sponsor.new(sponsor_params)
  if @sponsor.save
flash[:info] = "Sponsor added."
redirect_to sponsors_path
  else
render 'new'
  end
else
  redirect_to root_path
end
  end

  private
def sponsor_params
  params.require(:sponsor).permit(:name, :phone, :description,
  :contact_email, :contact_url,
  :current)
end
end



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


Re: [Rails] Re: Developing WITHOUT Vagrant/VirtualBox

2015-12-02 Thread Jason Hsu, Ruby on High Speed Rails
How long ago was this?  According to the spec sheet 
(http://www.dell.com/downloads/us/products/optix/gx270_spec.pdf), the Dell 
Optiplex 270 came with Windows 2000 or XP and an 800 MHz Pentium processor. 
 This sounds like a relic from about 2001 or 2002, which is eons ago when 
it comes to computers.  Given that Ruby on Rails is much more demanding of 
computer resources than word processing, spreadsheets, email, or casual web 
browsing, I can't imagine trying to get anything done on such a clapped-out 
beater.

On Wednesday, December 2, 2015 at 4:35:29 PM UTC-6, dana tassler wrote:
>
> It was quite bad. A dell optiplex GX270. I remember its model number 
> because it haunts my nightmares. 
>
> We now have some speedy workstations but for some time it was rough. We'd 
> rarely run tests because they took so long and caused the PC to become 
> unresponsive.
>

-- 
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/b78c8a8d-1a68-4c11-89d5-0617ddce1b5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Developing WITHOUT Vagrant/VirtualBox

2015-12-02 Thread Jason Hsu, Ruby on High Speed Rails
What kind of "workstation" were you provided?  It sounds like your employer 
provided you a computer from the Windows 98 era.  I'm surprised that your 
employer couldn't even cough up $50-100 for a used desktop PC.

On Wednesday, December 2, 2015 at 12:49:17 PM UTC-6, dana tassler wrote:
>
> Hi Jason,
>
> I used to develop inside a virtual machine as well (VMWare and VirtualBox) 
> but made the switch to development on the same operating system for 
> hardware reasons. The "workstation" I was provided with didn't have the 
> specifications to run a virtual machine inside its host operating system.
>
> Even though sometimes it's frustrating, having to work through missing 
> dependencies and the like is a good experience. I work on a small team 
> where both of us are full-stack developers. When something goes wrong we 
> can only rely on one another and have to solve problems with no other 
> assistance.
>
> Being able to scrap a VM instance or reset it surely is convenient but I 
> feel that it prevents you from gaining some development (system 
> administration, really) experience.
>
>

-- 
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/c9d254e5-0e72-4dbc-b9bd-166bec59fa8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Developing WITHOUT Vagrant/VirtualBox

2015-12-02 Thread Jason Hsu, Ruby on High Speed Rails
I regard Vagrant as indispensable for Ruby on Rails development.  (My setup 
is at https://github.com/jhsu802701/vagrant-debian-jessie .)  Before I 
learned to use Vagrant, I used VirtualBox directly for Ruby on Rails 
development.

That said, I also know that most people rely on Ruby on Rails installed 
directly on the host OS.  I never liked this setup, because there was no 
way to return Ruby on Rails to its initial state.  If anything went wrong, 
then I either had to troubleshoot the Ruby on Rails setup or reinstall Ruby 
on Rails.  I was unable to proceed any further on the project until I 
resolved this matter.  Additionally, there's also the "works on my machine" 
problem.  There were times when I tried to transfer my Rails app to another 
machine or deploy it, only to be greeted by very long error messages 
because of setup details that I forgot.  There were also times when I 
published a Ruby gem, only to get weird errors when I tried to use it. 
 These problems were most likely to crop up when I used "gem install" to 
install a Ruby gem but forgot to add the gem to the Gemfile/gemspec or when 
I made changes to the Gemfile/gemspec.

As a result, I insist on using Vagrant so that I can return Ruby on Rails 
to its initial state.  I also insist on including in each project a setup 
script that handles the setup AND testing.  When I rebuild my Vagrant box, 
git clone the project, and run the setup script, all of the tests should 
proceed as expected.  If that's the case, then I am assured that I have 
covered all of my bases.  If I get errors, or if strange things happen, 
then I know that I haven't covered all of my bases and need to update my 
setup script/instructions.

That said, I'd like to hear from those of you who are still part of the 
vast majority who use Ruby on Rails directly on the host OS.  How do you 
deal with the issues that prompted me to use VirtualBox/Vagrant?  (I think 
that gemsets are a popular solution.  Is this correct?)

-- 
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/f36b1ac4-811f-4c4a-a2a0-be8f86ac494f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Dynamic Links within a namespace

2015-11-12 Thread Jason Or
This worked perfectly! Thank you!!!

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

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


[Rails] Namespaces, dynamic links and routing

2015-11-06 Thread Jason O
Hello all!

I am new to all of this and I am trying to accomplish a couple things, I am 
hoping that someone will be able to assist me… 

First - 

I am trying to set up a namespace within a dynamic link. I have created an 
admin namespace and I need to following link to go to ../admin/people/xxx


<%= link_to(person) do %>
  <%= person.fname %> <%= person.lname %>
<% end %>
<%= person.title %>
<%= person.position.capitalize %>



Secondly, the current route resolves to address.com/people/{:id} and I 
would like to it resolve to address.com/{:user_name} and I am not sure how 
to get this to work. I have tried a few different options but I am not 
quite sure what I am doing here. 

resources :people, only: [:index, :show] do
   resources :pubs, except: [:create, :new, :edit, :destroy]
end


I have attempted to add  —>get 'people/:id/user_name' => 
'people#user_name', as: :user_name
but this has not worked. 

Thanks for any help!

Jason

-- 
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/9fe9baeb-6e78-46d2-bdde-4c04207d0c6e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Andriod tablets

2015-08-26 Thread Jason Weber
hello, im new to learning ruby, does anyone know if you can use a tablet to 
run ruby or do you need a computer to run it?

-- 
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/7fc6632c-fd25-4a4e-ba2b-9f1561daa4e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Docker for Ruby on Rails

2015-08-19 Thread Jason Hsu, Ruby on High Speed Rails
RVM problems (or possible RVM problems) are rare but have happened to me.

A much more common situation I've run into is a cascade of error messages 
when I tried to transfer my project to another development environment or 
when I tried to deploy my project.

In the case of Ruby gems, I've had times when I thought I was finished with 
my gem development, only to find I was missing one last critical step when 
I tried to use my gem in another gem or in a Rails app.  This is why I 
insist on having the ability to quickly reinstall RVM.  My Debian Stable 
Vagrant box allows me to do this in minutes.  It's not an option when using 
Ruby on Rails directly on the host OS.

For Rails projects, I've had times when my app worked in one development 
environment but didn't work when I tried to transfer my work to another 
development environment or when I tried to deploy it in production, and I'd 
get flooded with error messages.

My Vagrant base box gives me a known good reference setup that behaves 
exactly the same every time, even on bad hair days and even when the cosmic 
dice come up snake eyes.  For my Ruby gems, I now maintain a test_gem.sh 
script that does the setup and testing.  When I rebuild my Vagrant box and 
git clone my Ruby gem source code, I just run this script to verify that 
everything works as expected.  For my Rails apps, I now maintain a 
test_app.sh script that does the setup and testing.  When I rebuild my 
Vagrant box and git clone my Rails app source code, I just run this script 
to verify that everything works as expected.

Using Ruby on Rails directly installed on the host OS doesn't give me the 
ability to reinstall Ruby on Rails in a reasonable amount of time.  When it 
comes to picking my primary development environment, this is a dealbreaker 
for me.  The only reason I'd bother installing Ruby on Rails directly on 
the host OS is to have the ability to address complaints that my code 
doesn't work in OS X or Windows.

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


Re: [Rails] Docker for Ruby on Rails

2015-08-19 Thread Jason Hsu, Ruby on High Speed Rails
By "reset", I'm talking about returning Ruby on Rails to its original state 
from just after you first installed it and before you did anything with it.

My Debian Stable Vagrant base box comes with RVM pre-installed, along with 
multiple versions of Ruby, each with multiple versions of Rails.  This 
takes several hours to build, but I use a Packer script to automate the 
process.  The end result is stored as my Vagrant base box.

If you decided to use the "rvm implode" command just for kicks, how long 
would it be before you could start working on your Rails projects again? 
 If you rely on Ruby on Rails installed directly in your host OS, this 
would take hours.  On the other hand, if you were using my Vagrant box, it 
would be just a matter of destroying and rebuilding the box, and you'd be 
back in business in just a few minutes.

Since Docker avoids the overhead of having a virtual machine (which has to 
be booted up), the Docker way would allow you to return to the original 
state immediately.  You can be back in business in seconds.

On Wednesday, August 19, 2015 at 2:02:03 PM UTC-5, Hassan Schroeder wrote:
>
>
> Just curious -- what exactly do you mean by "reset" here? 
>
> And what is the perceived problem with "reinstalling"? A fresh rails 
> install on Ruby 2.2.3 just now took ~30 seconds on a relatively old 
> MacbBook Air, and half that time was building nokogiri extensions. 
>
>

-- 
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/2238f657-e1af-4948-8274-3eb602cdf0a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Docker for Ruby on Rails

2015-08-19 Thread Jason Hsu, Ruby on High Speed Rails
Is anyone here using Docker for Ruby on Rails?

I've been boning up on Docker due to the promise of being able to reset 
Ruby on Rails instantly.  (It takes a few minutes to destroy and rebuild my 
Debian Stable Vagrant box.  And forget about trying to reinstall Ruby on 
Rails if you have it installed directly on the host OS.)

If you're using Docker for Ruby on Rails, I'd like to learn more about your 
workflow.  My standard operating procedure is to boot up my Debian Stable 
Vagrant box (https://github.com/jhsu802701/vagrant-debian-jessie-rvm) in 
one window, open up additional tabs in my command line shell program, and 
use "vagrant ssh" to enter my Vagrant box in these extra tabs.  I use one 
terminal window for running the Rails server, one of running Guard, and one 
for executing other commands.  I keep a browser window open for viewing my 
site locally.  If I'm using the SQLite database in development, I use the 
SQLite browser program on my host OS to look at the data.  If I'm using the 
PostgreSQL database in development, I use the pgadmin3 program on my host 
OS to look at the data.

If you're using Docker for Ruby on Rails, I'd like to learn about your 
workflow.  How do you go through Michael Hartl's Rails Tutorial the Docker 
way?

-- 
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/3339c5a0-4d8e-46c7-90f6-cf8af470944b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Restrict application layout for certain views

2015-08-09 Thread Jason Walsh
Dave Aronson wrote in post #1176892:
> On Sat, Jul 25, 2015 at 3:44 PM, Jason Walsh 
> wrote:
>
>> Is there any way to change / restrict the application layout for certain
>> views?
>
> You can do that by specifying the layout in the controller.  See:
>
>   http://guides.rubyonrails.org/layouts_and_rendering.html#the-layout-option
>
> -Dave
>
> --
> Dave Aronson, consulting software developer of Codosaur.us,
> PullRequestRoulette.com, Blog.Codosaur.us, and Dare2XL.com.

Thanks

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

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


[Rails] Restrict application layout for certain views

2015-07-25 Thread Jason Walsh
Hi folks

Is there any way to change / restrict the application layout for certain
views?

For example, I don't want to render the header for a certain view, is
there any code such as:

<% if View != show.html.erb%>
<%= render 'layouts/header' %>
 <% end %>

Thanks in advance

Jason

-- 
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/7eb3dbd5e7e4800c8fa041ad40b376c4%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Search Form On New/Edit View

2015-07-14 Thread Jason Smith
Hello Everyone,

  Scenario:  I have a view with a form for entering a new (and separate 
view with form for editing) a software defect, for example.  On these same 
views (new and edit) I want users to be able to use a second form to search 
for one or more customers that found this defect.  This search form will 
allow users to page through results and select one or more customers that 
this defect was found by.  Note the search results and paging will be 
displayed in the same new and edit views rather than a different view or 
pop-up window.  When the user saves the new or edited defect then these 
selected customers should be saved with the appropriate associations in the 
database.

  I have found a RailsCast (#37 Simple Search Form) that I can follow to 
implement a simple search but this example utilizes the Index action.  I am 
definitely in the learning phase of both Ruby and Rails.  Can anyone 
recommend keywords for my Google-Fu or a brief sketch of how I might 
approach this scenario?  I'm willing to do the research and leg work if 
someone can spin me in the right direction.  :)  I've included links to 
code and the live site under development if anyone wants to see what I'm 
shooting for--this is/will be Open Source when complete.  Thanks much for 
your time!

  Sincerely,

  Jason Smith
  QualityAddict

Code | https://github.com/QualityAddict/quality-nexus
Live | http://qualitynexus.herokuapp.com/home

-- 
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/34aa7229-2153-4093-bab6-367acbe9c43f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Correcting "scope access" warning from Rails Best Practices

2015-06-30 Thread Jason Hsu, Ruby on High Speed Rails
The code in question works, but Rails Best Practices docks me with a scope 
access warning.  The code in question is:

  def show
# NOTE: rails_best practices recommends using scope access
redirect_to(root_path) unless current_user == User.find(params[:id])
@user = User.find(params[:id])
  end

How can I get this code to comply with the scope access standard?

-- 
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/98301ec8-a9b0-4bda-982a-34417a67e173%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Testing: executing "visit" command ends session

2015-06-26 Thread Jason Hsu, Rubyist
I get error messages that indicate that nobody is logged in.  The admin 
should be able to view the admin index page, but the users and the general 
public should not be able to.  Unfortunately, the test doesn't show that 
the admin can view the admin index page.  While this works in my 
development environment, it doesn't work in the test environment.

On Thursday, June 25, 2015 at 11:41:29 AM UTC-5, Frederick Cheung wrote:

> What do you mean by "kills the session". What happens? How does the test 
> fail? 
>
> Fred 
>
> > The source code is: 
> > 
> > login_admin('elle_...@example.com ', 'Harvard Law', 
> false) 
> >   
> >   
> > 
> > # View admin index 
> >   
> >   
> > 
> > admin_path = root_path + '/admins' 
> >   
> >   
> > 
> > click_on 'Profile' 
> >   
> >   
> > 
> > 
> > 
> > 
> >   
> >   
> > 
> > visit admin_path # NOTE: using the 'visit' command loses the 
> session 
> >   
> >   
> > 
> > 
> > 
> > 
> >   
> >   
> > 
> > @a1.reload 
> >   
> >   
> > 
> > #assert_equal current_path, '/admins' 
> >   
> >   
> > 
> > assert_text 'Vivian' 
> >   
> >   
> > 
> > assert_text 'Kensington' 
> >   
> >   
> > 
> > assert_text 'Elle' 
> >   
> >   
> > 
> > assert_text 'Woods' 
>
>

-- 
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/ecc77f37-9620-4dca-b6f2-8b5659ae1c3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Testing: executing "visit" command ends session

2015-06-26 Thread Jason Hsu, Rubyist
The problem is that the session is lost as soon as the "visit" command is 
invoked.  How do I get the test to retain the session?

Also, that link you cited revolves around RSpec instead of Minitest.

Are there any good examples of someone who has successfully done what I'm 
trying to do?  I can't possibly be the first person to use Minitest for 
testing the visibility of a page for different types of users.

On Thursday, June 25, 2015 at 11:31:18 AM UTC-5, Ruby-Forum.com User wrote:
>
> Hello Jason, 
>
> I think need to change some code. You need to test sections of your app 
> independently, so if you want to check if the view is only available for 
> Admins, you can login it with test methods provided by Devise and 
> later, visit the admins_path. 
>
> Instead of call login_admin, you can use: 
>login_as(user, :scope => :user) 
>visit admin_path 
>
># asserts... 
>
> In another test, check if an admin can login with the form (like 
> login_admin). You need to set Warden to test mode including this line at 
> top of your integration tests: 
>
>include Warden::Test::Helpers 
>Warden.test_mode! 
>
> More info at: 
> https://github.com/plataformatec/devise/wiki/How-To:-Test-with-Capybara 
>
> Regards! 
>
> -- 
> Posted via http://www.ruby-forum.com/. 
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+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/ddf66cd1-2b16-4443-9c7c-a6c26986aba5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Testing: executing "visit" command ends session

2015-06-25 Thread Jason Hsu, Rubyist
The code in question is at 
https://github.com/jhsu802701/generic_app_template/blob/master/test/integration/admins_view_test.rb
 
.

I've used the Devise gem to create users and admins.  I've successfully 
made the admin index page visible ONLY to admins, but it's failing the 
tests (Capybara and minitest).  For some reason, executing the "visit" 
command kills the session.  WHY?  What should I be doing about this?

The source code is:

login_admin('elle_wo...@example.com', 'Harvard Law', false)  # View admin 
index  admin_path = root_path + '/admins'  click_on 'Profile'  
  visit admin_path # NOTE: using the 'visit' command loses the session  
  @a1.reload  #assert_equal current_path, '/admins'  assert_text 'Vivian'  
assert_text 
'Kensington'  assert_text 'Elle'  assert_text 'Woods'


-- 
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/0eb82e88-304d-4858-a1cf-07c52e2c227d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Testing for redirects

2015-06-21 Thread Jason Hsu, Rubyist
I have an app with admin users created with the devise gem.

I have succeeded in redirecting anyone who tries to access an admin profile 
page but is NOT logged in as an admin to the root_path 
(http://localhost:3000).

However, I'm having difficulty getting the tests to pass in my integration 
test.  (I'm using Capybara and minitest.)

In the admins controller, the first line under "def index" is:
redirect_to(root_path) unless admin_signed_in?

In the integration test, I start with the following code:
test_prepare # From test/test_helper.rb
@u1 = users(:connery) # From test/fixtures/users.yml
@a1 = admins(:vivian_kensington) # From test/fixtures/admin.yml
visit new_user_session_path
fill_in('Email', with: 'sean_conn...@example.com')
fill_in('Password', with: 'original')
uncheck('Remember me')
click_button('Log in')
visit admin_path(@a1)

How do I test for the redirect?  The path parameter at this point is nil 
and NOT root_path or '/'.

-- 
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/040a3c5b-7719-4642-bd37-d95132f22317%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] #count and #size

2015-06-09 Thread Jason Waldrip
I have been pretty frustrated with the inconsistencies of AR's #count 
method. In my humble opinion, the count method should always return an 
integer. The "grouped count" functionality is powerful but should not be 
lumped in with the main #count method. This is further seen by the 
inconsistency on the #size method where in the result is either the result 
of #count if unloaded or #length of the results when loaded. I plan as 
proposing this as a PR, but thought to first start it as a discussion in 
the google group. Please share your opinions on my proposal.

Cheers,

Jason Waldrip
CTO @ Brandfolder.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/122c51de-2854-4a4d-b6bd-1a435f6795b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Rails/Devise: testing the user confirmation process

2015-06-03 Thread Jason Hsu, Rubyist
BACK STORY: I'm working on a Rails app template that is similar to the 
Rails Tutorial Sample App.  The idea is to begin every app I ever start 
with a pre-made template so that I don't have to plow through chapters 3 
through 10 in Rails tutorial.  I can have the app set up AND tested in just 
a few minutes.  My source code is at 
https://github.com/jhsu802701/generic_app_template .

MY TASK: I'm in the process of replacing the Sample App's original user 
authentication system with the devise gem.  How do you set up the 
integration test for the CONFIRMATION process?  When users sign up or 
change their email addresses, they are sent a link.  When they visit that 
URL, they are confirmed.

MY PROBLEM: Are there any good examples on how to test the user 
confirmation process?  In Minitest/Capybara tests I've set up, visiting the 
links doesn't seem to confirm the URL, and I get error messages saying that 
I used the wrong confirmation code.  I can't possibly be the first person 
in the history of the world to try to do this, right?

-- 
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/78e5a4d1-294f-4646-9681-97a4f8f1e0b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Do you use the devise gem to create users in your Rails apps?

2015-04-26 Thread Jason Hsu, Rubyist
I'd like to hear your opinions.

On the one hand, it's clearly easier in the short run to use the devise gem.

On the other hand, Rails Tutorial maintains that modifying an off-the-shelf 
solution is a "black box" and can be more work than creating the user 
functionality from scratch.

-- 
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/853e10d3-7a3e-411b-8dce-26a2745398b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Updated Rails site: Lose Money Fast

2015-04-23 Thread Jason Hsu, Rubyist
Check out my new and improved version of my Rails site Lose Money Fast at 
https://losemoneyfast.herokuapp ­ 
. You can buy thousands of fictional Mega Millions and Powerball tickets 
every virtual week. You never run out of money, but your return on 
"investment" is tracked.

-- 
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/0e818d00-3cdd-4d7f-8813-d6edaf05ffe9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Debian Jessie Vagrant box with RVM

2015-04-23 Thread Jason Hsu, Rubyist
Debian Jessie is about to become the new Debian Stable.  I have released my 
new Debian Jessie Vagrant box at 
https://github.com/jhsu802701/vagrant-debian-jessie-rvm as a replacement 
for the old Debian Wheezy Vagrant box.  The old Debian Wheezy Vagrant box 
is still available, but I will not be making any more releases.  The 
scripts I use for making the new Jessie-based Vagrant box are at 
https://github.com/jhsu802701/packer-debian-jessie .

The biggest improvements in my Vagrant box are:
1.  Ansible comes pre-installed.
2.  The latest versions of Ruby 2.2, 2.1, and 2.0.0 are included.  For each 
of these versions of Ruby, Rails 4.2.1, 4.2.0, 4.0.8, and 3.2.16 are 
pre-installed.  (4.2.0 is the version of Rails used by the current Rails 
Tutorial Sample App.  Rails 4.0.8 and 3.2.16 are used by past versions of 
the Rails Tutorial Sample App.)

-- 
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/d2d2022b-7d2d-4420-a375-3a490cf2b043%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] NEW GEM: GenericGem

2015-03-19 Thread Jason Hsu, Rubyist
Check out my new gem called GenericGem, which streamlines the process of 
creating a new gem.  There are many generic and routine tasks common to all 
or most gems but are all too easy to forget.  GenericGem takes care of 
these tasks so that you can focus on your gem's unique capabilities.

Just enter "gem install generic_gem" to install GenericGem and then enter 
the command "generic_gem" to use it.  The URL is:
https://github.com/jhsu802701/generic_gem

GenericGem requests the name of your gem, your name, and your email 
address.  It then uses the "bundle" command to create the gem and then 
AUTOMATICALLY takes care of the generic details common to all or most of 
the gems you will likely create.  These details include:
1.  Adding the Code of Conduct
2.  Adding the MIT license WITH your name filled in for the copyright
3.  Providing your name and email address in the gemspec
4.  Setting up RSpec testing capability
5.  Making the bin/setup and bin/console scripts executable
6.  Adding and setting up your Rakefile for testing your gem
7.  Adding a one-step gem_test.sh script: Just enter "sh gem_test.sh" to 
execute "bundle install" AND "rake".
8.  Adding a one-step gem_install.sh script: Just enter "sh gem_install.sh" 
to install the gem you are developing.
9.  Adding tmp*, .DS_Store, and *.gem to your .gitignore file
10.  Updating your README.md file to include the above gem testing and 
installation procedures

-- 
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/70769d8d-e673-431c-ba7f-91a223c2585d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Database connections, I cannot decide which way I should go!

2015-03-16 Thread Jason O
Hello all! And thanks for your help and input.

I am in the process of building my first project for the company I work for 
and I am stumped as how to tackle my database information problem. 

What I am dealing with is a database with a list of users and a separate 
table with a list of articles that users have written. The PEOPLE table 
includes the normal name conventions as so forth, but also a value called 
Author_ID which is derived from a government entity. 

The ARTICLES table has a value which lists the authors of the articles, 
normally 2-7 authors per article. Here, I am not sure if this short be an 
array or just a string. I currently have it as a string. Also of note, some 
articles may have multiple authors within my PEOPLE table, most will also 
have authors that are not in my table as they are not a part of my faculty. 

As I have it set up currently I was attempting to do a has_many through 
connection, but was unsure of how to call the articles for that particular 
Person. And as I work through the problem in my head I am not sure I even 
need to make a join of the tables.

My desired end result: Each faulty member's personal page needs to pole the 
ARTICLES table and list any articles that have the corresponding Author_ID. 
I am happy to supply any code that I currently have if it is requested. 

Thank you again for your time and help!

Jason

-- 
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/1fba54c0-b5e2-40a3-8667-84df92bea5f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: YOUTUBE: Debian Stable Vagrant Box (plus music)

2015-03-06 Thread Jason Hsu, Rubyist
As an added bonus, these videos have catchy musical soundtracks.

-- 
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/469e48c7-e2a7-48a0-8887-98de75c39780%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] YOUTUBE: Debian Stable Vagrant Box (plus music)

2015-03-06 Thread Jason Hsu, Rubyist
Check out my 3-part YouTube presentation on my Debian Stable Vagrant box at 
http://www.youtube.com/playlist?list=PLfd4iay29eVBey-eRCvjWvO1pGj4_E_Us .  
Your Ruby on Rails environment will be ready to roll in MINUTES instead of 
hours.  If RVM behaves in unexpected ways, or if you need to make sure that 
your Gemfile, gemspec, setup scripts, and setup instructions are complete, 
it only takes one command and a few minutes to return to the original Ruby 
on Rails setup.

Because my Vagrant box is based on Debian Stable instead of Ubuntu, 
maintenance needs are very modest.  This means you can spend more time 
working on your projects instead of waiting for long updates to finish.

-- 
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/85a02925-ba7d-4bbc-9030-5a7af3ffb183%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] PostgreSQL password in environment variables

2015-02-20 Thread Jason Hsu, Rubyist
I've heard that using environment variables to provide the password and 
other PostgreSQL parameters is the way to go.

Is the Nitrous.io way (explained at http://help.nitrous.io/postgres/) the 
way you do it?  Or is there a better way?


-- 
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/79c7d9c3-1be8-4483-b92b-4d7537cfa532%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Heroku: Why isn't the config/database.yml file relevant?

2015-02-20 Thread Jason Hsu, Rubyist
As you know, Heroku uses the PostgreSQL database by default.

However, when you deploy an app that you created with the use of SQLite in 
the development environment, the config/database.yml file on the Heroku 
server is still configured for SQLite.

Exactly how does Heroku make the config/database.yml file relevant?  How 
does the app get the database name, username, and password in the Heroku 
environment?

-- 
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/e7e38b8c-3694-4b3e-9305-c858a74e28d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Rails redirect_to new behaviour with Ruby 2.2 / Rails 4.2?

2015-02-13 Thread Jason Hobbs
Add gem 'responders' to your Gemfile.
redirect_to was moved to that.

On Friday, February 13, 2015 at 10:02:04 AM UTC-6, Ruby-Forum.com User 
wrote:
>
> Trying to upgrade from Ruby 2.0 / Rails 4.0 to Ruby 2.2 / Rails 4.2, I 
> face a surprising error when logging into my application (based on Rails 
> Tutorial by M. Hartl): 
>
> Controller: SessionsController#create 
> Instruction: redirect_to root_url 
> Error message: wrong number of arguments (2 for 1) 
>
> Here is the sessions controller: 
>
> class SessionsController < ApplicationController 
>
>   def new 
>   end 
>
>   def create 
> user = User.find_by_login(params[:session][:login]) 
> if user && user.authenticate(params[:session][:password]) 
>   sign_in user 
>   redirect_to root_url 
> else 
>   flash.now[:error] = 'Invalid login/password combination' 
>   render 'new' 
> end 
>   end 
>
>   def destroy 
> sign_out 
> redirect_to root_url 
>   end 
>
> end 
>
> Here is the routes file: 
>
> ODQStairs::Application.routes.draw do 
>
>   resources :requests 
>
> #static pages 
>   get '/help',  to: "static_pages#help" 
>   get '/about', to: "static_pages#about" 
>   get '/contact',   to: "static_pages#contact" 
>
> #root definition 
>   root to: "dashboards#home" 
>
> #routes 
>   resources :sessions, only: [:new, :create, :destroy] 
>   get '/signin',  to: 'sessions#new', via: :get 
>   match '/signout', to: 'sessions#destroy', via: :delete 
>
>   resources :parameters_lists do 
>   resources :parameters 
>   end 
>   ... 
>
> I did not find anything in Rails upgrade guides regarding the 
> redirect_to function. Your help is welcome! Thanks! 
>
> -- 
> Posted via http://www.ruby-forum.com/. 
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To 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/03975270-790a-4a7a-9813-d7e1153c0328%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: [Newbie] Filtering Index page

2015-02-10 Thread Jason O
Thank you for the welcome and the response! 

What have given me works great! With the exception of the {:class => 
"button"} which throws up a wrong number of arguments (4 for 0..3) error. I 
am looking into this to see if I can find out more. I tried this also with 
the button_to which makes the button but does not do the filtering. More 
and more stuff to research. 

Thank you again for your help!

-- 
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/511855b5-919b-43a4-8ff5-d9ea87e06e86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] [Newbie] Filtering Index page

2015-02-09 Thread Jason O
Hello all and thank you for your time and help.

I am working on my first big project and one of the requests that I have is 
to host a directory list people, with the option to click from an array of 
buttons with the different position titles. Button examples being: Staff, 
Faculty, Grad Student, etc.  I have the index listing the full directory 
currently, but I was hoping someone would be willing to point in a 
direction to look for examples of how to set this up, or a gem that might 
be beneficial. I am researching on my own, but I do not feel I am finding 
quite what I am seeking.

Thanks again for any help!

Jason

-- 
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/ade15b3b-b4fd-4224-9da1-6d0ee44bd0eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] RVM alternatives

2015-02-05 Thread Jason Hsu, Rubyist
I understand that some people prefer rbenv, chruby, and perhaps other 
programs over RVM for Ruby on Rails.  There is a list of alternatives at 
https://github.com/wayneeseguin/rvm/blob/master/docs/alt.md .

I'm using RVM, because that's what most people use and because that's what 
railstutorial.org advocated in the past.  (railstutorial.org now recommends 
nitrous.io.)  RVM has worked well enough for me, and I have no plans at 
this time to switch my Debian Stable Vagrant box to something else.  I 
haven't tried the alternatives, but I'd like to hear from those of you who 
prefer one or more of the alternatives.  I don't have any plans to switch 
anytime soon, but it's good to have an open mind in the event that my needs 
change or RVM makes changes that I don't like.

What method of getting Ruby on Rails do you prefer, and why?  What don't 
you like about RVM?

-- 
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/68a72edf-97b7-4830-96c0-c7d9b97b285a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Why isn't Vagrant standard practice?

2015-02-04 Thread Jason Hsu, Rubyist
I'm doing my part.  My Debian Stable Vagrant box with pre-installed Ruby on 
Rails (https://github.com/jhsu802701/vagrant_debian_wheezy_rvm) is now part 
of my standard operating procedure.

Is there any reason that use of Vagrant is NOT already universal in the 
Ruby on Rails community?  The issues that Vagrant addresses for me are:
1.  How can you get Ruby on Rails up and running in minutes instead of 
hours WITHOUT Vagrant?  At an event like Startup Weekend or a 24-hour web 
site challenge, the Drupal, PHP, and Django people can get their teammates 
ready to roll in minutes.  If you have to install Ruby on Rails without 
Vagrant, the process requires several steps and takes hours.  Thanks to 
Vagrant, that will never again delay myself or anyone on my team from 
getting started.
2.  How do you install Ruby on Rails in Windows?  Very few Ruby on Rails 
developers use Windows, which makes it hard to get help.  Thanks to 
Vagrant, this will never be a problem for myself or anyone I work with, 
because it's cross-platform.
3.  If RVM behaves in ways that you don't expect, what do you do?  It has 
happened to me a few times, though I was able to Google the error messages 
and figure out how to fix it.  With Vagrant, I can just rebuild the box and 
return to original conditions.  If you don't have Vagrant, you may not be 
able to do anything in Ruby on Rails until you resolve the issue.
4.  How do you know that your gemspec/Gemfile and setup instructions are 
complete?  This has come back to haunt me when I deployed Rails apps or 
published Ruby gems.  If you remove dependencies from the Gemspec/Gemfile, 
those gems are NOT automatically uninstalled.  (And the same goes for other 
gems that they pulled in.)  Using Vagrant to rebuild my Ruby on Rails 
environment allows me to cover these bases.  (And since I keep my projects 
in the shared directory, I don't have to re-download them.)

-- 
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/f63f0237-e128-4491-9667-4d8e02c4dda8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   3   4   5   6   7   8   >