Re: [Rails] How do I run an action on a dedicated thread?

2019-08-08 Thread Eric Jesse Knutsen
San, I hope you know I meant no offense. This is a strange issue to have
and is normally indicative of an architectural design flaw and without
having more details that might violate your nda, we can only go based on
facts entered into evidence, to borrow a phase from legal.

An application can be internally perfect, with a flawless deployment, but
the external communication/network aspect is the gotcha.

Unfortunately, I am not familiar with any way build right into rails to do
this outside of backgrounding and/or micro-servicing the process that
invokes the external. Generally, that is how one prevents the application
from locking when dealing with things that are outside ones control. The
major reason for this is that runners like puma/unicorn/insert yours here
want to be agnostic themselves. If you have the ability to do it from a dev
ops perspective, then that would likely be the best option for it if you
can not isolate it out some other way.


On Thu, Aug 8, 2019 at 2:31 PM San Ji  wrote:

> Architecture wise the application is way better than average Rails apps
> IMO.
> The dependency direction is one way internally, with no cyclic dependency.
> (even with the ActiveRecord class, that in almost all other Rails app
> contains cyclic dependency between models)
> Network perspective may suggest otherwise, but the business logic is truly
> not relying on any external service, completely agnostic to user
> interfaces, data storage, and external network traffics.
> The unit tests run blazingly fast because they are genuinely
> side-effect-free, including side-effects from the database. (No mocking, no
> database cleaner, no factory bot/fabrication gem, no-nonsense)
>
> The application is not a legacy one, and I can vouch for it that there is
> no problem with the software architecture.
> It is the business that creates a weird flow of traffic, and the reasons
> are legit. (It is weird in a sense that it is quite unusual for Rails app,
> but not in a bad sense.)
>
> This is an enterprise world. And I am in the process of open-sourcing the
> tool I use to manage all the complexity.
> If you are interested, you peek into the architecture of this application
> with gem "midnight-rails" (used as the main backbone of this application),
> the source code is now available but currently no documentation.
>
> The problem I have can be solved at the expense of DevOps operation, I
> wonder if there is the other way around using just the ruby 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/bdc5b160-efbe-4bba-9bc0-f3e889ed082d%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAOMcp-AMbcxi8mfc2Fn1ChzntYQWiGGK%2BCJLp_FL6%2BUCG%2BXbXQ%40mail.gmail.com.


Re: [Rails] How do I run an action on a dedicated thread?

2019-08-08 Thread Eric Jesse Knutsen
hmm...

It sounds like you might want to isolate this into a micro-service then.
Honestly, and architecturally, it sounds like this process flow might need
a redesign, especially as it relies on a resource external to the main
application. I am guessing that this is legacy?

Is this application accessed from command line normally?



On Thu, Aug 8, 2019 at 1:09 PM San Ji  wrote:

> Thank you for the reply, but the client is not a web browser, so no
> javascript and no polling possible, plus not in our control.
> To be more specific the call to the external service is via a headless
> browser, not even a direct HTTP call, and you cannot push the data along
> with the request made by the headless browser.
> As I said, there is no obvious way around it business-wise, but it is
> quite impractical to explain the whole situations, plus some NDA involved.
>
> --
> 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/80cfa78d-a199-40a9-8654-0665943b7686%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAOMcp-BM%3D7KS%2BpTYD4iBkW4tLkqVjRBcO1yZB3X%3DPPwECsqktA%40mail.gmail.com.


Re: [Rails] How do I run an action on a dedicated thread?

2019-08-08 Thread Eric Jesse Knutsen
It sounds like this might be best served by encapsulating the caller in a
job and then setting up a dedicated queue for that job in your background
processes, if I am understanding correctly what this is. If you need to
have the results display when complete then you could set up a poller or a
channel to listen to it. By shifting it to the background you can prevent a
deadlock.

On Thu, Aug 8, 2019 at 12:24 PM San Ji  wrote:

> Hi
> I run Rails on quite a complicated situation but the gist of it is, in my
> application, it is possible that an action can call some external services
> which fetch data from another action via another http call to the
> application itself. (Basically a cyclic http call)
>
> It is by design and there is no other obvious way around it.
>
> To prevent a deadlock in production, I wanted to make sure that, there is
> always a single thread available to run those certain action. Basically, I
> want to dedicate one thread to run that action, and no other actions.
>
> Did you know how can I accomplish 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/263cc035-170e-4c45-b5d7-f047662c8416%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAOMcp-AqZeqKA_F1CuwLDvChS0AGF1%3DcLiii2arRqjz-0tWTSg%40mail.gmail.com.


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

2019-06-10 Thread Eric Anderson
I've found the rails-env-credentials 
<https://github.com/sinsoku/rails-env-credentials> gem useful for this. Not 
sure how compatible it will be with the upcoming Rails 6 support but its 
been working great for my app.

Eric

On Sunday, June 9, 2019 at 9:40:05 PM UTC-4, Jason Fleetwood-Boldt wrote:
>
> 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/3a996a87-4ad2-465d-85cc-d129d7ee72d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: How do you generically call a scope on a model?

2019-03-18 Thread Eric Anderson
I don't have the answer to your question, but I wouldn't say `send` is 
inherently evil. It all depends on the source of the data. If your `scope` 
argument is some meta-programming (i.e. the value is defined by the 
programmer) then it can be safe to use. If it is user input then obviously 
you would want to whitelist against the scopes you have defined.

Also remember scopes are just a class method that returns an 
ActiveRecord::Relation. I.E. you may have a "scope" that wouldn't be on any 
Rails internal data structure if the `scope` method was not used to define 
it.

Eric

On Sunday, March 17, 2019 at 3:56:05 PM UTC-4, Walter Lee Davis wrote:
>
> I want to (in a metaprogramming context) invoke a scope on an ActiveRecord 
> based model. I know the name of the scope, but I don't want to use `send` 
> to do this, because send can be evil. I know that ActiveRecord defines a 
> class method named scope that gathers up these scopes somewhere internally, 
> but I can't figure out where that is, or how you can pick one out of the 
> stack to execute. 
>
> What is the best equivalent to this (completely made-up example): 
>
> def call_scope(model, scope = 'all') 
>   model.send scope.to_sym 
> end 
>
> The key feature is that we late-evaluate which model and which scope, so 
> it can be used inside an enumerator, and doesn't rely on knowing the exact 
> parties in play. 
>
> Would this be a good place for class_eval? (I just tried that, and it 
> works) 
>
> def call_scope(model, scope = 'all') 
>   model.class_eval scope.to_s 
> end 
>
> Is there something more Rails-like I could/should use? 
>
> Am I wrong about send? 
>
> Thanks in advance, 
>
> Walter

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


[Rails] Re: PostgreSQL Array column + has_many association

2019-02-04 Thread Eric Anderson
I don't think this is supported out-of-the-box in Rails but I did see this 
extension a while back that appears to add what you are looking for:

https://github.com/marshall-lee/has_array_of

Haven't personally used it but looks promising.

Eric

On Wednesday, April 11, 2018 at 7:51:00 AM UTC-4, Carlos Ferreira da Silva 
wrote:
>
> I'm trying to use an array column to crete an association between 2 
> models. I remember that in the past this was working, but I think something 
> has changed and now it's not working anymore. Here is the deal:
>
> Ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]
> Rails 5.1.5
>
> app/models/user.rb
> # Having the columns id, name, email
> class User < ApplicationRecord
> end
>
> app/models/group.rb
> # Having the columns id, name, user_ids[]
> class Group < ApplicationRecord
>   has_many :users, primary_key: :user_ids, foreign_key: :id
> end
>
> And the oddest thing about this is that the following works fine:
> Group.first.users
>
> It gives me the list of the users with the ids filled on that field, but 
> the following doesn't work:
> Group.first.users.load
>
> It gives me an empty list. And, since the load method doesn't work, I 
> cannot do any operation like #each or #to_a.
> I already did some dig up, and found the source of the problem here:
>
> https://github.com/rails/rails/blob/v5.1.5/activerecord/lib/active_record/associations/association_scope.rb#L79
>
> The first command don't replace the original value by a Replaceable, the 
> second does. Maybe we just need a ReplaceableArray or something like that, 
> or I'm missing something here.
>
> Can anyone help me with that?
>

-- 
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/1bf2d946-5602-4337-acd3-f19f7460285a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Why are has_one through has_one relationships not constructible in the same way that has_many throug

2018-11-10 Thread eric
Per my question on 
StackOverflow: 
https://stackoverflow.com/questions/53243674/build-methods-for-has-one-though-has-one

And the subsequent answer there, I'm wondering why has_one relationships 
don't behave the same way as has_many relationships in terms of building 
nested associations. 

I assume there is good reason for this, however, I personally feel like 
this is a bug

-- 
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/8470ea92-f9a6-4b1d-bcc0-428f07b408fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Proper Coding Question

2018-10-04 Thread Eric Anderson
I agree with Rob that it is in the realm of taste and preference. I 
wouldn't have something like this in my view:

users = User.where(active: 
true).join(:transactions).merge(Transaction.where('total > 1000'))
form.collection_select users, :id, :name

This would be putting model level stuff in my view as the guide Rob linked 
to recommended against. That first line should be wrapped up in a model 
scope or something.

But in the case where I simply want all scoped users I think putting 
`policy_scope(User)` in the view is ok. You could create a helper method 
maybe like:

def scoped_users
  policy_scope User
end

Then in the view pass `scoped_users` to `collection_select`. But is that 
really much different than `policy_scope(User)`. IMHO the view is less 
interacting with the model layer but declaratively specifying to the helper 
how it should interact with the model layer.

Also the fact that Pundit has explicitly created this helper method of 
`policy_scope` 
<https://github.com/varvet/pundit/blob/master/lib/pundit.rb#L154> means it 
considers it ok to call from the view.

Again this is getting in the realm of tasted. If I started coding in an app 
and I saw that the policy_scope was called in the controller and the result 
was passed to the view I wouldn't think bad of it.

Eric

On Thursday, October 4, 2018 at 4:19:47 AM UTC-4, Rob Jonson wrote:
>
> Hi John,
>
> firstly - I don't know pundit, so this is only general advice.
> secondly - we're definitely in the realm of taste and preference here 
> rather than 'ok' and 'not ok'
>
> having said that, my two pence:
>
> the rails style guide says 'Never call the model layer directly from a 
> view'
> https://github.com/rubocop-hq/rails-style-guide#no-direct-model-view
>
> I like to think of views as pieces that will do their job of displaying a 
> thing with minimal worrying about the details of the thing. The view 
> shouldn't be worrying about things like user policy
>
> also I wouldn't want authorisation logic in the views just because it is 
> easy to lose track of (and that stuff is important).
>
> my suggestion would be
>
> a) You say you're calling a lot of policy_scope(User)
> this sounds like something where a lot of your calls probably need to find 
> a single scoped user at the start. If this is the case, use a before_action
>
> before_action :get_policy_scoped_user, only: [:show, :update, :destroy]
>
> I'd be tempted to have that before_action assigning an @policy_user which 
> I can then pass down to the view.
> this keeps the authorisation stuff in the controller, and the view can 
> just display a user's stuff without worrying about what is allowed
>
> so - back to your select. I'd write the view so that it will work when 
> passed any kind of user and doesn't know or care what kind of user it is 
> dealing with.
> It just so happens that your controller only passes down a scoped user.
>
>  
>
>

-- 
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/2f473c1e-706d-4998-bb63-8bff53fdd73a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Proper Coding Question

2018-10-03 Thread Eric Anderson
There is an `collection_select` form builder that will do the `collect` for 
you. So:

<%= f.collection_select :user, policy_scope(User), :id, :name %>

If you are not using a form builder then 
`options_from_collection_for_select` is useful for the same purpose.

If those helpers cannot be used directly for some reason I create a custom 
helper.

For example if I wanted to include the user's security role as a data 
attribute for some sort of UJS behavior I might have:

def user_options selected
  policy_scope(User).collect do |user|
content_tag 'option', user.name,
  value: user.id,
  selected: user.id == selected,
  data: { role: user.role }
end.join.html_safe
end

Then in the view I might have:

<%= form.select :user_id, user_options form.object.user_id %>

On Tuesday, October 2, 2018 at 7:20:48 AM UTC-4, John Sanderbeck wrote:
>
> Good Morning Everyone...
>
> I have a coding question just so I am clear on the proper way to do this...
>
> To start, I have an app that I use Pundit in to control access to data, so 
> I have a lot of calls that are like policy_scope(User)
>
> What is the proper way to populate a select on a form with this data?
>
> Initially I was just using policy_scope(User).collect
>
> However I don't think it is proper to use this in a view, is it?
>
> If not, what is the proper way to pull this data and provide it to the 
> form?
>
> Recently I have moved some of these to helpers and created a method like 
> "users_for_select"
>
> John
>

-- 
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/5e458afd-02e5-4508-bbd6-2f1612d46727%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [Rails] Heroku and Javascript

2018-07-25 Thread Eric Jesse Knutsen
Anything in browser javascript console? Is anything not being served properly? 
And, dumb question time but we all have these kind of moments, did you remember 
to precompile, and are all your JS libraries set to have pointers to the 
compiled locations of assets?

Cheers,

Jess


From: David Merrick
Sent: Thursday, July 26, 2018 12:24 AM
To: Ruby on Rails: Talk
Subject: [Rails] Heroku and Javascript

I have built a games website in Rails. Runs run on local system. But when 
deployed to Heroku the Javascript requests either run slow or freeze. Often the 
whole page freezes. I'm only using one Dyno as I'm still in the testing phase.

Heroku doesn't have any suggestions to fix the problem

Slug size on Heroku is 36.5. MiB of 500 MiB

Cheers Dave
-- 
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/a26ccf22-ab23-4a07-a354-cd861ae9aa37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

-- 
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/5b595131.1c69fb81.a9594.1cec%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Why doesn't collection=objects on has_many :through trigger destroy callbacks on the join model?

2015-12-17 Thread Eric Krause
I responded on stackoverflow, but I'll do here as well so that it is 
covered everywhere on the internet.

In my case I was doing something similar to what you were doing and was 
running into the same issue with the join table being deleted instead of 
destroyed.

I started looking through the code and I believe the documentation is just 
out of date.
[has_many_through_association](https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/has_many_through_association.rb#L131)

All you need to do is add the dependent: :destroy to the has_many :through 
relationship.

class User
  has_many :partnerships, dependent: :destroy
  has_many :partners, through: :partnerships, dependent: :destroy
end

The pain I was dealing with was:

user.partner_ids = [1,2,3]
#creates the relationships
user.partner_ids = []
#was deleting the records from partnerships without callbacks.

The dependent: :destroy on the partners relationship fixed that.  Callbacks 
are now being run and things are good again.

Eric

On Monday, December 14, 2015 at 5:43:57 PM UTC-7, spike22 wrote:
>
> I've asked this on on Stack Overflow but didn't receive much of a response:
>
> The Rails 4 documentation says this regarding destroy callbacks on the 
> join model for a has_many :through relationship:
>
> collection=objects Replaces the collections content by deleting and 
> adding objects as appropriate. If the :through option is true callbacks in 
> the join models are triggered except destroy callbacks, since deletion is 
> direct.
>
> Thankfully it's documented at least, but I want to know why on earth this 
> is the case? It makes more sense to trigger destroy callbacks (or have the 
> option to) on a :through since these types of models can have destroy 
> callbacks and other associations.
>
> In my case I had a has_and_belongs_to_many relationship on the join 
> tables model off to another model. The records on that second join table 
> would never be deleted when the associated records on the first join table 
> were deleted. I resorted to this which feels hacky, and I have to repeat 
> myself on each side of the :through relationship:
>
> class SchoolsTemplate < ActiveRecord::Base
>
>   belongs_to :school
>   belongs_to :template
>
>   has_and_belongs_to_many :groups
>
> end
>
>
> class School < ActiveRecord::Base
>
>   has_many :schools_templates, dependent: :destroy
>   has_many :templates, through: :schools_templates, before_remove: 
> :remove_groups_school_templates
>
>   private
>   def remove_groups_school_templates(template)
> schools_templates.where(template: template).first.groups.clear  end
>
> end
>
> There's a validation to 'ensure' uniqueness on the join tables records 
> between the two foreign keys, so that's why I can call first in the 
> callback.
>

-- 
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/36dc4015-38a9-47de-bc37-99c4b3eca150%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Re: Why doesn't collection=objects on has_many :through trigger destroy callbacks on the join model?

2015-12-17 Thread Eric Krause
I just did that this morning.

On Thursday, December 17, 2015, spike22 <bren...@spikeinsights.co.nz> wrote:

> Hi Eric, that's really interesting! I'll give it a whirl and report back
> :) I might do a documentation pull request to clarify this too.
>
> Have a great day!
>
> Brendon
>
> On Friday, December 18, 2015 at 6:23:50 AM UTC+13, Eric Krause wrote:
>>
>> I responded on stackoverflow, but I'll do here as well so that it is
>> covered everywhere on the internet.
>>
>> In my case I was doing something similar to what you were doing and was
>> running into the same issue with the join table being deleted instead of
>> destroyed.
>>
>> I started looking through the code and I believe the documentation is
>> just out of date.
>> [has_many_through_association](
>> https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/has_many_through_association.rb#L131
>> )
>>
>> All you need to do is add the dependent: :destroy to the has_many
>> :through relationship.
>>
>> class User
>>   has_many :partnerships, dependent: :destroy
>>   has_many :partners, through: :partnerships, dependent: :destroy
>> end
>>
>> The pain I was dealing with was:
>>
>> user.partner_ids = [1,2,3]
>> #creates the relationships
>> user.partner_ids = []
>> #was deleting the records from partnerships without callbacks.
>>
>> The dependent: :destroy on the partners relationship fixed that.
>> Callbacks are now being run and things are good again.
>>
>> Eric
>>
>> On Monday, December 14, 2015 at 5:43:57 PM UTC-7, spike22 wrote:
>>>
>>> I've asked this on on Stack Overflow but didn't receive much of a
>>> response:
>>>
>>> The Rails 4 documentation says this regarding destroy callbacks on the
>>> join model for a has_many :through relationship:
>>>
>>> collection=objects Replaces the collections content by deleting and
>>> adding objects as appropriate. If the :through option is true callbacks in
>>> the join models are triggered except destroy callbacks, since deletion is
>>> direct.
>>>
>>> Thankfully it's documented at least, but I want to know why on earth
>>> this is the case? It makes more sense to trigger destroy callbacks (or have
>>> the option to) on a :through since these types of models can have destroy
>>> callbacks and other associations.
>>>
>>> In my case I had a has_and_belongs_to_many relationship on the join
>>> tables model off to another model. The records on that second join table
>>> would never be deleted when the associated records on the first join table
>>> were deleted. I resorted to this which feels hacky, and I have to repeat
>>> myself on each side of the :through relationship:
>>>
>>> class SchoolsTemplate < ActiveRecord::Base
>>>
>>>   belongs_to :school
>>>   belongs_to :template
>>>
>>>   has_and_belongs_to_many :groups
>>>
>>> end
>>>
>>>
>>> class School < ActiveRecord::Base
>>>
>>>   has_many :schools_templates, dependent: :destroy
>>>   has_many :templates, through: :schools_templates, before_remove: 
>>> :remove_groups_school_templates
>>>
>>>   private
>>>   def remove_groups_school_templates(template)
>>> schools_templates.where(template: template).first.groups.clear  end
>>>
>>> end
>>>
>>> There's a validation to 'ensure' uniqueness on the join tables records
>>> between the two foreign keys, so that's why I can call first in the
>>> callback.
>>>
>> --
> 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/eGJRC4hDDuQ/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> rubyonrails-talk+unsubscr...@googlegroups.com
> <javascript:_e(%7B%7D,'cvml','rubyonrails-talk%2bunsubscr...@googlegroups.com');>
> .
> To post to this group, send email to rubyonrails-talk@googlegroups.com
> <javascript:_e(%7B%7D,'cvml','rubyonrails-talk@googlegroups.com');>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/9eb239ab-b444-4b74-837d-503b589516a2%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/9eb239ab-b444-4b74-837d-503b589516a2%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 

Eric Krause

-- 
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/CAMtp6HebCtGxrnNExkU0S6v-cK2Q4%3D71%2B_y-g44Bos1GBRkYCw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] one liner with rescue is good style ?

2015-11-05 Thread Eric Lavigne
This is terrible style and is strictly forbidden in our codebase.

In the example below, probably the programmer thought that an exception
always meant that quote_responses was nil instead of an array, and that nil
should be treated as an empty array. That works fine... until another
source of errors comes along. What if the interface for arrays changed such
that count was no longer a valid method, so that this function always
returned false? Instead of an obvious exception and a quick fix, the code
would just return the wrong answer all the time. (We actually had this sort
of problem when switching Rails versions.) Or maybe the name of the rqstate
variable changed, and the "undefined variable" exception resulted in this
code returning false - same problem.

Something like this is much better. Handle the particular situation that is
causing exceptions, so that real problems will remain visible.

def receipt_available
   (quote_responses || []).count > 0 && rqstate.eql?("submitted")
end

Save exception handling for cases where it is really needed. If there's no
way to avoid the exception, and you have a way to recover from the
exception, then catch only that very specific type of exception. You can
also have a high-level exception handler for the entire application that
takes care of reporting uncaught exceptions so that they can be fixed.


On Thu, Nov 5, 2015 at 3:47 PM, wbsurf...@yahoo.com <wbsurf...@gmail.com>
wrote:

>
> I was reading some ruby one liners. The rescue style seems to make it easy
> to write short pieces of code, but it feels like I am forcing an error and
> then just ignoring it in some cases. I guess I am an older programmer and
> was never encouraged to write this sort of code, but do most people feel
> like this is good style ?
>
> def receipt_available
>quote_responses.count > 0 && rqstate.eql?("submitted") rescue false
> end
>
> obviously if  code had alot of possible errors to recover from you
> wouldn't do that
>
> --
> 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/d9c52162-6942-4f29-a2f1-2287af28ae8b%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/d9c52162-6942-4f29-a2f1-2287af28ae8b%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Eric Lavigne
Director of Software Development
MCNA Systems
elavi...@mcna.net
Mobile: (352) 871-7829

CONFIDENTIALITY NOTICE: This electronic message transmission from MCNA
Dental is intended only for the individual or entity to which it is
addressed. This e-mail may contain information that is privileged,
confidential and exempt from disclosure under applicable law. If you are
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication and attachments is strictly
prohibited by the standards set forth in the HITECH Act of 2009. If you
received this e-mail by accident, please notify the sender immediately and
destroy this e-mail and all copies.  Thank you.
-
200 W Cypress Creek Rd
Fort Lauderdale, FL
http://mcna.net

-- 
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/CADoJS-vVM0-AExoo5yowEEJnx5m41EXYhCyY-6AiZBUu0NHPjg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] LOOP ARRAY OF HASHES

2015-06-16 Thread Simon Eric
Please how can i loop this to have all values of _id, contact, sent,
answer, repondant?

{
result : [
{
_id : null,
contact : 45684,
sent : 0,
answer : 0,
repondant : 0
},
{
_id : vms,
contact : 6340,
sent : 6340,
answer : 0,
repondant : 0
},
{
_id : sms,
contact : 27356,
sent : 41344,
answer : 0,
repondant : 0
}
],
ok : 1
}


Thank you very much

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

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


[Rails] NET/HTTP GET VALUE

2015-03-07 Thread Simon Eric
I have two app in rails that communicate between net/http:
In the first app controller is something like so:

class WebservicesController  ApplicationController
  require 'net/http'
  require uri
   layout 'admin'
  def ws
uri = URI(http://localhost:3001/api/ws;)
response = Net::HTTP.post_form(uri, {'campaign_id' = '1'})
debugger
 @res = response
   respond_to do |format|
  format.html
end
  end
end


In the second app controller is like that:

class ApiController  ApplicationController
  def ws
begin
   debugger
req =Smsq.find_by_campaign_id(params[:campaign_id])
   return req

rescue Exception = exception
  return NOK  : #{exception.message}
end
  end
end



But response return: `#Net::HTTPOK:0x00090ab708`



But how can i get the result for this query

`Smsq.find_by_campaign_id(params[:campaign_id])` in my first app??

I have result when i try to the console.

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


[Rails] Keep data on the field after submit a form with error

2015-02-07 Thread Simon Eric
After validation, I got error and return back to :action = :new. Some
field on form already filled, so I want to keep them filled after error
message too. How it can be done in rubyonrails4?

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


[Rails] Re: Couldn't find 'migration' generator

2014-09-26 Thread eric felleiter
Isn't it just script/generate migration


On Thursday, September 25, 2014 3:13:12 AM UTC-4, M,Gopi M.gopinath wrote:

 Hi,

 I am trying to add a field in a existing table (database) in Rails 2.3.5 
 and ruby 1.8.6.

 I gave a command to generate a migration, Here as follows,

 ruby script/generate migration AddwebToDistributors website:string

 But I am getting a error, saying that Couldn't find 'migration' 
 generator 

 Can anyone help me to solve this issue.

 Best Regards,

 *Gopinath M*


  

-- 
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/585768a9-605c-4a9e-8d59-babdfe7553b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: openstreetmap as link

2014-08-15 Thread Eric Saupe


%= link_to('my_link') do %
  divOPEN STREETMAP CONTENT/div% end %

You can put a div inside of the a generated by link_to and this will work 
for you but putting block elements inside of a is not really good 
practice. Instead you could try span instead of div


On Friday, August 15, 2014 1:46:31 AM UTC-6, Melb01 wrote:

 Hi,
 I am using openlayers gem to show a openstreetmap as div in a a rails app
 how can I make this div as a link to an other page  in the rails app using 
 link_to tag


 regards


-- 
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/9a2863d8-5118-45e7-96c4-f16532ece901%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Can't mass-assign protected attributes: item

2014-08-14 Thread Eric Saupe
Quick Google search brought 
up http://railscasts.com/episodes/26-hackers-love-mass-assignment and this 
StackOverflow question, 
http://stackoverflow.com/questions/6163759/cant-mass-assign-protected-attributes.

On Thursday, August 14, 2014 3:31:12 PM UTC-6, Fernando Aureliano wrote:

 Hi!

 I'm using the version of that gem 
 https://github.com/crowdint/acts_as_shopping_cart for rails 3

 I did evething with ythe convetions names. But I'm getting the error Can't 
 mass-assign protected attributes: item

 class ShoppingCartsController  ApplicationController

   before_filter :extract_shopping_cart

   def create

 @product = Video.find(params[:product_id])

 @shopping_cart.add(@product, @product.price)

 redirect_to shopping_cart_path

   end

   def show



 *Heres my model ShoppingCart*

 # == Schema Information
 #
 # Table name: shopping_carts
 #
 #  id :integer  not null, primary key
 #  created_at :datetime not null
 #  updated_at :datetime not null
 #

 class ShoppingCart  ActiveRecord::Base
 acts_as_shopping_cart

   attr_accessible :price

   #accepts_nested_attributes_for :price
 end



 *and the model ShoppingCartItem*

 # == Schema Information
 #
 # Table name: shopping_cart_items
 #
 #  id :integer  not null, primary key
 #  owner_id   :integer
 #  owner_type :string(255)
 #  quantity   :integer
 #  item_id:integer
 #  item_type  :string(255)
 #  price  :float
 #  created_at :datetime not null
 #  updated_at :datetime not null
 #

 class ShoppingCartItem  ActiveRecord::Base
   attr_accessible :owner_id, :owner_type, :quantity, :item_id, :item_type, 
 :price
   acts_as_shopping_cart_item
 end


 Someone saw something that I'm not seeing?

 Thanks!















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


Re: [Rails] conditional layout question ? sidebar visible on all pages except the login page.

2014-08-13 Thread Eric Saupe
No, the render command goes in your layout in this case since it is 
something that a lot of your views are using.

%= render “sidebar” unless current_page?(login_path) %




On Wednesday, August 13, 2014 12:32:48 AM UTC-6, Roelof Wobben wrote:

 oke , and put this in the controller ??

 Roelof


 Op woensdag 13 augustus 2014 08:26:52 UTC+2 schreef matt:

 you could use current_page with route to check the page.  Ex:
 render “sidebar” unless current_page?(login_path)

 Matt
 On Aug 13, 2014, at 2:20 AM, Roelof Wobben rwo...@hotmail.com wrote:

 Hello, 

 Allmost all pages have the same layout except the login page.
 There the sidebar with menu is not visible. 

 Is there a way to tell rails that when im on the login page the sidebar 
 must not be visible. 

 Roelof


 -- 
 You received this message because you are subscribed to the Google Groups 
 Ruby on Rails: Talk group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to rubyonrails-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/fc9ab3e6-e2ee-4417-adab-653d4f210fa5%40googlegroups.com
  
 https://groups.google.com/d/msgid/rubyonrails-talk/fc9ab3e6-e2ee-4417-adab-653d4f210fa5%40googlegroups.com?utm_medium=emailutm_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/f7e3e9f9-25b4-40ae-a865-6eb40a72ca3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] conditional layout question ? sidebar visible on all pages except the login page.

2014-08-13 Thread Eric Saupe
You still need _path. So in your case, since it is the login which I'm 
assuming is new_admin_session, it would be

%= render “sidebar” unless current_page?(new_admin_session_path) %

On Wednesday, August 13, 2014 1:20:26 PM UTC-6, Roelof Wobben wrote:

 Rake routes : 


   Prefix Verb   URI PatternController#Action  
   
   
   

 new_admin_session GET/admins/sign_in(.:format)  
 devise/sessions#new   
   
  

 admin_session POST   /admins/sign_in(.:format)  
 devise/sessions#create
   
  

 destroy_admin_session DELETE /admins/sign_out(.:format) 
 devise/sessions#destroy   
   
  

 cancel_admin_registration GET/admins/cancel(.:format)   
 devise/registrations#cancel   
   
  

admin_registration POST   /admins(.:format)  
 devise/registrations#create   
   
  

new_admin_registration GET/admins/sign_up(.:format)  
 devise/registrations#new  
   
  

   edit_admin_registration GET/admins/edit(.:format) 
 devise/registrations#edit 
   
  

   PATCH  /admins(.:format)  
 devise/registrations#update   
   
  

   PUT/admins(.:format)  
 devise/registrations#update   
   
  

   DELETE /admins(.:format)  
 devise/registrations#destroy  
   
  

dashboard_show GET/dashboard/show(.:format)  dashboard#show
   
   


  root GET/  dashboard#show
   

 I tried already  new_admin_registration but then I see the same error 
 message.

 Roelof


 Op woensdag 13 augustus 2014 21:09:30 UTC+2 schreef Germano Teixeira:

 run rake routes in cosole to see your login path.


 2014-08-13 16:08 GMT-03:00 Germano Teixeira germ...@gmail.com:

 You have to look in your routes file what is your login_path. 
 login_path is just a example.


 2014-08-13 15:24 GMT-03:00 Roelof Wobben rwo...@hotmail.com:

 Sorry but I do not work.  I see a message that login_path is not known. 
 I think that devise is messing things  up. 

 Roelof

 Op woensdag 13 augustus 2014 17:56:23 UTC+2 schreef Eric Saupe:

 No, the render command goes in your layout in this case since it is 
 something that a lot of your views are using.

 %= render “sidebar” unless current_page?(login_path) %




 On Wednesday, August 13, 2014 12:32:48 AM UTC-6, Roelof Wobben wrote:

 oke , and put this in the controller ??

 Roelof


 Op woensdag 13 augustus 2014 08:26:52 UTC+2 schreef matt:

 you could use current_page with route to check the page.  Ex:
 render “sidebar” unless current_page?(login_path)

 Matt
 On Aug 13, 2014, at 2:20 AM, Roelof Wobben rwo...@hotmail.com 
 wrote:

 Hello, 

 Allmost all pages have the same layout except the login page

Re: [Rails] Error after calling bundle install (Ruby on Rails installation) (Mac OS X)

2014-08-06 Thread Eric Saupe
OSX doesn't have apt-get. You should use brew 
instead,http://stackoverflow.com/questions/19688424/why-is-apt-get-function-not-working-in-terminal-on-mac-osx-10-9,
 but 
this can occasionally have different installation instructions. Make sure 
you are installing MySQL correctly for Mac.

On Wednesday, August 6, 2014 11:18:14 AM UTC-6, Michael Sutyak wrote:

 I'm pretty sure I installed everything required.  What could be missing on 
 Mac OS X?

 On Wednesday, August 6, 2014 12:01:53 AM UTC-7, Colin Law wrote:

 On 5 August 2014 23:53, Michael Sutyak msu...@gmail.com wrote: 
  I am trying to initialize a rails application, and I am running into 
 some 
  issues. When running: rails new . -m 
  https://raw.github.com/RailsApps/rails-composer/master/composer.rb 
  
  I run into the issue: 
  
  Could not find gem 'quiet_assets (= 0) ruby' in the gems available on 
 this 
  machine. 
  Run `bundle install` to install missing gems. 
  
  When I try to run bundle install, it gives me this error: 
  
  An error occurred while installing mysql2 (0.3.16), and Bundler cannot 
  continue. 
  Make sure that `gem install mysql2 -v '0.3.16'` succeeds before 
 bundling. 
  
  When I run that command, I get: 
  
  ERROR:  Error installing mysql2: 
  ERROR: Failed to build gem native extension. 

 You probably have not installed everything that is necessary for 
 building gem native extensions.  What you need depends on which OS you 
 are using.  For example, on Ubuntu, I do 

 sudo apt-get install build-essential bison openssl libreadline6 
 libreadline6-dev curl git-core \ 
 zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev autoconf 
 libc6-dev ncurses-dev automake \ 
 libtool 

 Colin 



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


[Rails] Re: General Information About RoR

2014-08-04 Thread Eric Saupe
Hey Diego,

First, there is nothing wrong with running a local web server and just 
having your browsers access it. Since the only users of your application 
are going to be those on the same network it really doesn't matter if it is 
hosted externally or internally and since the Internet going down is an 
issue I would go ahead with your idea to just host it locally.

Second, since it is a web application and would be accessed through 
browsers it would have access to any peripherals the computer had. In this 
case when you print a web site or PDF it doesn't matter where that came 
from but that it is open in your browser. This means you can generate the 
receipts in a new window/tab and just have them hit print.

On Monday, August 4, 2014 6:47:33 AM UTC-6, Diego Dillenburg Bueno wrote:

 Dear Rail Developers,

 I'm kinda new to the RoR world and would appreciate if someone with the 
 knowledge helped me out sorting some things.

 I got a new project that I'm supposed to do but came up with some 
 questions, it's basically a system to manage a Pub with basic 
 funcionalities like inventory control, cash flow and client controls 
 (probably with a bar code card).

 Firstly we thought of doing it desktop based, in something like C# or 
 Java, but came up with the idea of implementing it on a web based system. 
 Then we came up with a couple questions:

 1. The business couldn't rely on his ISP stability, as here we have really 
 poor ISP, and the fact of the internet going down would probably ruin the 
 entire night at the pub. The question would be: as if it were developed in 
 Rails, what would be the praticability to run it in a local server 
 primarily, but exporting it to a remote server everyday so it could also be 
 accessed from home. I know it seems to go against some laws of web system 
 developing, but would be quite the better solution for us. Or if there is 
 any other ways to manage it locally, without entirely needing an internet 
 connection, in the worst of the cases.

 2. As it is a business, here in Brazil, we have now the option to print 
 the customer's receipt for his IRS declarations. So the other question 
 would be: if possible, how is this integration from RoR with periphericals, 
 such as printers, would follow? Or if should it be done in anything else 
 such as js. Honestly, I have no clues yet on how to do so.

 Will appreciate any help given!

 Thanks in advance,
 Diego Dillenburg Bueno



-- 
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/fc354f4f-830a-4b3a-b17f-18fae414dd55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Re: General Information About RoR

2014-08-04 Thread Eric Saupe
I was just thinking about doing something really quick like rendering a 
page that is printer friendly using Rails and just having them hit CTRL+P 
but if you wanted to bypass that and send it straight to the printer that 
works too. From a quick Google search it seems the best way is to issue OS 
commands using Ruby and sending it a generated PDF file. Here is a 
Stackoverflow link about it but I'm sure more searches will reveal better 
information, 
http://stackoverflow.com/questions/1608593/printing-a-file-to-a-printer-in-ruby.
 
The only reason I would do it the other way is just to allow the user to 
preview the file before it is sent to the printer but if everything works 
and you don't mind reprinting or whatever then sending it straight to the 
printer would be faster for the user.

Hope that helps.

On Monday, August 4, 2014 11:26:50 AM UTC-6, Diego Dillenburg Bueno wrote:

 A quick update:

 it seems that the printer manufacturer provides a integration tool built 
 in a dll file. If that is of any help towards the solution.


 2014-08-04 14:22 GMT-03:00 Diego Dillenburg Bueno diegodi...@gmail.com 
 javascript::

 Hey Eric,

 thanks for the attention, really helped me sorting out on what 
 technologies to use. We were fearing that it would end out looking like 
 some kind of poor job building it on a local server.

 As of the integration with periphericals I hadn't thought about this 
 approach, it seems pretty straight forward, but another question that came 
 up is: is there any known gem to help handling these communication cases?

 Again, thanks for the attention.

 Regards,
 Diego Dillenburg Bueno


 2014-08-04 12:46 GMT-03:00 Eric Saupe eric...@gmail.com javascript::

 Hey Diego,

 First, there is nothing wrong with running a local web server and just 
 having your browsers access it. Since the only users of your application 
 are going to be those on the same network it really doesn't matter if it is 
 hosted externally or internally and since the Internet going down is an 
 issue I would go ahead with your idea to just host it locally.

 Second, since it is a web application and would be accessed through 
 browsers it would have access to any peripherals the computer had. In this 
 case when you print a web site or PDF it doesn't matter where that came 
 from but that it is open in your browser. This means you can generate the 
 receipts in a new window/tab and just have them hit print.


 On Monday, August 4, 2014 6:47:33 AM UTC-6, Diego Dillenburg Bueno wrote:

 Dear Rail Developers,

 I'm kinda new to the RoR world and would appreciate if someone with the 
 knowledge helped me out sorting some things.

 I got a new project that I'm supposed to do but came up with some 
 questions, it's basically a system to manage a Pub with basic 
 funcionalities like inventory control, cash flow and client controls 
 (probably with a bar code card).

 Firstly we thought of doing it desktop based, in something like C# or 
 Java, but came up with the idea of implementing it on a web based system. 
 Then we came up with a couple questions:

 1. The business couldn't rely on his ISP stability, as here we have 
 really poor ISP, and the fact of the internet going down would probably 
 ruin the entire night at the pub. The question would be: as if it were 
 developed in Rails, what would be the praticability to run it in a local 
 server primarily, but exporting it to a remote server everyday so it could 
 also be accessed from home. I know it seems to go against some laws of 
 web system developing, but would be quite the better solution for us. Or 
 if 
 there is any other ways to manage it locally, without entirely needing an 
 internet connection, in the worst of the cases.

 2. As it is a business, here in Brazil, we have now the option to print 
 the customer's receipt for his IRS declarations. So the other question 
 would be: if possible, how is this integration from RoR with 
 periphericals, 
 such as printers, would follow? Or if should it be done in anything else 
 such as js. Honestly, I have no clues yet on how to do so.

 Will appreciate any help given!

 Thanks in advance,
 Diego Dillenburg Bueno

  -- 
 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 javascript:.
 To post to this group, send email to rubyonra...@googlegroups.com 
 javascript:.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/rubyonrails-talk/fc354f4f-830a-4b3a-b17f-18fae414dd55%40googlegroups.com
  
 https://groups.google.com/d/msgid/rubyonrails-talk/fc354f4f-830a-4b3a-b17f-18fae414dd55%40googlegroups.com?utm_medium=emailutm_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

[Rails] Re: password validation triggered even I update non-password attribute

2014-08-01 Thread Eric Saupe
I had this same problem a while ago. The issue comes in the 
update_attributes since it wants to update all of the attributes that are 
being passed to it, which is including an empty password. To fix it you'll 
need to do two things. First change the validates to only validate if a 
password is being passed.

validates :password, length: { minimum: 6 }, :if = :password


Second, remove the parameters for password if the are blank on your update 
method.

if params[:password].blank?
  params.delete(:password)
end

That should get you where you want to go.


On Friday, August 1, 2014 8:44:53 AM UTC-6, Ruby-Forum.com User wrote:

 I have a User model: 

   create_table users, force: true do |t| 
 t.string   name 
 t.string   email 
 t.datetime created_at 
 t.datetime updated_at 
 t.string   password_digest 
   end 
   add_index users, [name], name: index_users_on_name 

 Then, I have the following validation: 

 class User  ActiveRecord::Base 
   has_secure_password 
   validates :password, length: {minimum: 4} 
 end 

 Then, I update in my controller the name and email of a certain user: 

... 
 logger.debug(' new_values after: '+new_values.inspect) 
 if @user.update_attributes(new_values) 
   logger.debug('+ SUCCESS') 
   ... 
end 

 (new_values is of type ActionController::Parameters) 

 My log shows 

    new_values after: {name=, email=} 

 However, the update_attributes fails, and the error message says: 

   Password is too short (minimum is 4 characters) 

 What I don't understand is, that I don't supply a new password. Why, 
 then, is password validation triggered here? And how should I implement 
 this? 

 Background for this question: 

 This code is executed only, when a user wants to edit his profile data 
 (which, for the time being, consist only of name and email). It is 
 ensured that only a logged in user can execute this code, and only for 
 his own data. Therefore, I don't require to enter the password. He had 
 entered it anyway when logging in. 

 -- 
 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/ec3f3610-eb6d-446f-9543-fcb51342f4c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Variable + string to specify variable

2014-07-31 Thread Eric Saupe
I knew there would be a nice simpler Ruby way. I love the second solution, 
Rob. Below is the updated example.

id = 100
arrays = [Array.new, Array.new, Array.new]
arrays.sample.push(id)


On Thursday, July 31, 2014 8:45:33 AM UTC-6, Rob Biedenharn wrote:


 On 2014-Jul-30, at 10:59 , Eric Saupe eric...@gmail.com javascript: 
 wrote:

 To expand on what Scott is saying here is some code that gives an example 
 of what he is referring to.

 id = 100
 x  = rand(1..3)
 arrays = [Array.new, Array.new, Array.new]
 selected_array = arrays[x]
 selected_array.push(id)


 And to make it a bit more flexible, you could do:

 arrays = [ Array.new,  Array.new,  Array.new ]
 x = rand(arrays.size)
 arrays[x].push(id)

 or even:

 arrays = [ Array.new,  Array.new,  Array.new ]
 arrays.sample.push(id)

 http://www.ruby-doc.org/core-2.1.2/Array.html#method-i-sample

 -Rob


 On Tuesday, July 29, 2014 8:05:16 PM UTC-6, Scott Ribe wrote:

 On Jul 29, 2014, at 7:33 PM, Dave Castellano li...@ruby-forum.com 
 wrote: 

  Novice question: 
  
  I need to assign an item id to one of 3 arrays randomly but can't 
 figure 
  out how to specify the correct array by combining arr and the 
 randomly 
  generated number... 
  
  id = 100 
  x = rand(1..3) 
  
  arr1 = Array.new 
  arr2 = Array.new 
  arr3 = Array.new 
  
  selected_array =  #{'arr' + x}  *** Not sure how to do this  
  
  selected_array.push(id) 
  

 While you could append the name and eval, that's not really a clean 
 approach. Just use an array of arrays. Or if else... 


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





 -- 
 You received this message because you are subscribed to the Google Groups 
 Ruby on Rails: Talk group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to rubyonrails-ta...@googlegroups.com javascript:.
 To post to this group, send email to rubyonra...@googlegroups.com 
 javascript:.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/rubyonrails-talk/62d3b861-c606-4936-8540-08caae33e8fc%40googlegroups.com
  
 https://groups.google.com/d/msgid/rubyonrails-talk/62d3b861-c606-4936-8540-08caae33e8fc%40googlegroups.com?utm_medium=emailutm_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/931a7b70-e8bf-464a-90d8-ae0f4682ee3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Variable + string to specify variable

2014-07-30 Thread Eric Saupe
To expand on what Scott is saying here is some code that gives an example 
of what he is referring to.

id = 100
x  = rand(1..3)
arrays = [Array.new, Array.new, Array.new]
selected_array = arrays[x]
selected_array.push(id)



On Tuesday, July 29, 2014 8:05:16 PM UTC-6, Scott Ribe wrote:

 On Jul 29, 2014, at 7:33 PM, Dave Castellano li...@ruby-forum.com 
 javascript: wrote: 

  Novice question: 
  
  I need to assign an item id to one of 3 arrays randomly but can't figure 
  out how to specify the correct array by combining arr and the randomly 
  generated number... 
  
  id = 100 
  x = rand(1..3) 
  
  arr1 = Array.new 
  arr2 = Array.new 
  arr3 = Array.new 
  
  selected_array =  #{'arr' + x}  *** Not sure how to do this  
  
  selected_array.push(id) 
  

 While you could append the name and eval, that's not really a clean 
 approach. Just use an array of arrays. Or if else... 


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






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


[Rails] Re: Customise message for validates_uniqueness_of

2014-07-28 Thread Eric Saupe
This is along the lines of what Matt is referring to.

class DayValidator  ActiveRecord::Validator
  def validate()
if YOUR_TEST_FOR_INVALIDITY(record.day)
  date = Date::DAYNAMES[record.day]
  record.errors[:day]  already has a target #{date}
end
  end
end

class YourClass  ActiveRecord::Base
  validates_with DayValidator
end




On Friday, July 25, 2014 9:21:08 PM UTC-6, Ricky Hopkins wrote:

 I am trying to convert an integer to a DAYNAME in my validation message

 validates_uniqueness_of :day, scope: :store, :message = already has a 
 target for #{Date::DAYNAMES[self.day]}.

 This does not seem to work, I cannot access the day value.
 The following displays the correct value

 validates_uniqueness_of :day, scope: :store, :message = already has a 
 target for %{value}.

 This throws an error:

 validates_uniqueness_of :day, scope: :store, :message = already has a 
 target for #{Date::DAYNAMES[%{value}]}.


 Any help would be Amazing!


-- 
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/968ab5ce-dce8-4aa4-8db0-bc96f6b9eeaa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] undefined method `authenticate' for nil:NilClass

2014-07-21 Thread Eric Saupe
@Ian,

He is not using Devise if he is going through the Hartl tutorial. Scott's 
suggestion is the one that should be followed.

On Monday, July 21, 2014 10:36:01 AM UTC-6, Ian_Rgz wrote:

 It seems that you need to create the Devise mapping(If you're using 
 devise), to fix this you can:

 - Set the devise mapping inside a before block
 - Include Devise test helpers

 Here's a link to the Devise Wiki 
 https://github.com/plataformatec/devise#test-helpers

 Cheers,
 Ian


 2014-07-21 9:26 GMT-07:00 Scott Ribe scott...@elevated-dev.com 
 javascript::

 On Jul 21, 2014, at 10:19 AM, Roelof Wobben rwo...@hotmail.com 
 javascript: wrote:

   undefined method `authenticate' for nil:NilClass

 You're calling method authenticate nil. You need to look at your call to 
 authenticate, and figure out why the object is nil. (This could easily be 
 caused by a simple typo. Check variable names carefully.)


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




 --
 You received this message because you are subscribed to the Google Groups 
 Ruby on Rails: Talk group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to rubyonrails-ta...@googlegroups.com javascript:.
 To post to this group, send email to rubyonra...@googlegroups.com 
 javascript:.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/rubyonrails-talk/722ED808-DDC4-4D21-8AC4-A4C8FAEE329E%40elevated-dev.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/0b9ee9e8-ed44-4b28-a5ef-0b5ecb1fd681%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Re: Upload UTF-8 encoded textfile

2014-07-17 Thread Eric Saupe
Colin,

That shows how to create a Tempfile with a given encoding but the question 
is when a user uploads a file through a form and Rails creates a Tempfile 
is there a way to indicate that it should always create those Tempfiles 
with a default encoding such as UTF-8?

On Thursday, July 17, 2014 8:12:27 AM UTC-6, Colin Law wrote:

 On 17 July 2014 10:22, Ronald Fischer li...@ruby-forum.com javascript: 
 wrote: 
  As far I understand this article, this related to Rails 3 and MySQL, and 
  how to use UTF8 encoded data everywhere. I don't know about MySQL, but 
  Rails 4 and Ruby 2 with SQLite don't suffer this problem: I didn't have 
  any trouble, processing all kinds of Unicode characters with my 
  application, and processing the uploaded file also works fine, as long I 
  use my (not very elegant) trick to open it a second time with the 
  desired encoding. 
  
  It now occurs to me, that the question is maybe not Rails-specific, but 
  a general Ruby question - how to change the encoding of a Tempfile 
  object. 

 I have not been following this thread in detail, but [1] discusses how 
 to use the encoding option when creating a Tempfile. 

 [1] 
 http://www.ruby-doc.org/stdlib-1.9.3/libdoc/tempfile/rdoc/Tempfile.html 

 Colin 


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


Re: [Rails] Re: Upload UTF-8 encoded textfile

2014-07-17 Thread Eric Saupe
In that case is there something like a simple config change to be made in 
say config/application.rb that tells Rails how to encode created Tempfiles? 
If not would that be something that could/should be added to the Rails 
project itself?

On Thursday, July 17, 2014 8:51:30 AM UTC-6, Colin Law wrote:

 On 17 July 2014 15:42, Eric Saupe eric...@gmail.com javascript: 
 wrote: 
  Colin, 
  
  That shows how to create a Tempfile with a given encoding but the 
 question 
  is when a user uploads a file through a form and Rails creates a 
 Tempfile is 
  there a way to indicate that it should always create those Tempfiles 
 with a 
  default encoding such as UTF-8? 

 In that case it *is* a Rails specific issue, not a Ruby question as 
 suggested by the OP. 

 Colin 

  
  On Thursday, July 17, 2014 8:12:27 AM UTC-6, Colin Law wrote: 
  
  On 17 July 2014 10:22, Ronald Fischer li...@ruby-forum.com wrote: 
   As far I understand this article, this related to Rails 3 and MySQL, 
 and 
   how to use UTF8 encoded data everywhere. I don't know about MySQL, 
 but 
   Rails 4 and Ruby 2 with SQLite don't suffer this problem: I didn't 
 have 
   any trouble, processing all kinds of Unicode characters with my 
   application, and processing the uploaded file also works fine, as 
 long I 
   use my (not very elegant) trick to open it a second time with the 
   desired encoding. 
   
   It now occurs to me, that the question is maybe not Rails-specific, 
 but 
   a general Ruby question - how to change the encoding of a Tempfile 
   object. 
  
  I have not been following this thread in detail, but [1] discusses how 
  to use the encoding option when creating a Tempfile. 
  
  [1] 
  http://www.ruby-doc.org/stdlib-1.9.3/libdoc/tempfile/rdoc/Tempfile.html 
  
  Colin 
  
  -- 
  You received this message because you are subscribed to the Google 
 Groups 
  Ruby on Rails: Talk group. 
  To unsubscribe from this group and stop receiving emails from it, send 
 an 
  email to rubyonrails-ta...@googlegroups.com javascript:. 
  To post to this group, send email to rubyonra...@googlegroups.com 
 javascript:. 
  To view this discussion on the web visit 
  
 https://groups.google.com/d/msgid/rubyonrails-talk/6af117a7-b554-4ada-84b3-3a362c3e0973%40googlegroups.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/a9799dc2-78c3-4413-b5bb-999b8b89817b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Re: Upload UTF-8 encoded textfile

2014-07-17 Thread Eric Saupe
OK, so after some digging. It seems that when you create your new File 
object and set the encoding you may not need to read the Tempfile in its 
entirety. You can create a new File object using the Tempfile. 
File.new(my_temp_file, encoding: 'utf-8') and then use this file. It should 
be using the Tempfile and just creating a new pointer to that file with a 
new encoding. If you wanted to read the lines out individually and just use 
that original Tempfile you could use force_encoding('utf-8') on each line 
to make sure it is converting them to utf-8.

On Thursday, July 17, 2014 10:46:30 AM UTC-6, Ruby-Forum.com User wrote:

 Colin Law wrote in post #1152686: 
  On 17 July 2014 15:42, Eric Saupe eric...@gmail.com javascript: 
 wrote: 
  That shows how to create a Tempfile with a given encoding but the 
 question 
  is when a user uploads a file through a form and Rails creates a 
 Tempfile is 
  there a way to indicate that it should always create those Tempfiles 
 with a 
  default encoding such as UTF-8? 
  
  In that case it *is* a Rails specific issue, not a Ruby question as 
  suggested by the OP. 

 Indeed, you are right so far that it *might* be a Rails question. Still, 
 I wonder why (in general) it is not possible to change the encoding of 
 an existing (already open) Tempfile. Assuming that it is OK to rewind 
 the file, I don't see a technical reason, why this is not possible. 

 I don't think it would be a good idea to configure this on the Rails 
 side. Image the following scenario: We have a website, which allows 
 users to upload textfiles, the content of which will eventually go into 
 the database. Since we are generous about the encoding, we also provide 
 the user with a dropdown list to choose a suitable encoding. 

 When the user clicks the upload button, the controller gets the uploaded 
 file plus information about the encoding. Clearly, Rails can not 
 anticipate the encoding of the file. It just can upload the file 
 (binary), and provide the controller with an open file handle. 

 Now Ruby *does* have the set_encoding method for File, and Tempfile is-a 
 file, and set_encoding *can* be called - it just fails. We have nearly 
 everything in place. Now, if we can find out WHY set_encoding fails (and 
 this might be a generic Ruby question), we can find out what Rails (or 
 the programmer) can do to let things go smoothly 

 Ronald 

 -- 
 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/21394543-54bb-40b4-bb19-229300b9a4fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Upload UTF-8 encoded textfile

2014-07-16 Thread Eric Saupe
Does setting

config.encoding = utf-8

in your config/application.rb help? You'd also need to add 

# encoding: UTF-8

to the top of your file.

I was reading 
this http://craiccomputing.blogspot.com/2011/02/rails-utf-8-and-heroku.html 
which seems to discuss this problem.

On Wednesday, July 16, 2014 1:16:13 AM UTC-6, Ruby-Forum.com User wrote:

 Yes, it is, as I found by trial-and-error. Note that the object is not 
 just a File, it is of class Tempfile. I think this is quite common when 
 working with a Tempfile object. To make a Tempfile threadsafe, you have 
 to combine the creation of the filename and the creation of the file 
 into one call (otherwise you have a race condition if another process 
 tries to create a tempfile in the same directory and by accident comes 
 up with the same name). 

 While I didn't dive into the source code to see, how Rails is 
 implemented in this respect, it would be reasonable to assume, that for 
 the upload, a Tempfile object is created for read+write, the uploaded 
 file is written to it, and the file pointer is repositioned at the 
 beginning of the file, before it is handed over to the controller. Since 
 the uploading process can't know anything about the encoding, the file 
 must have been opened as a binary file. That's why I had the idea that I 
 just need to set the encoding to the desired value before starting to 
 read from the file. 

 -- 
 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/61c89b0b-a2df-481b-b317-f2f780cba188%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: SQL OR in RoR

2014-07-16 Thread Eric Saupe
@games = Game.sorted.where(home_team = :id OR away_team = :id, id: params
[:id])

That should do the trick for you. You can have a string inside of your 
where statement that equates to SQL. You can then have named parameters 
that are used throughout the query as I have done above. In this case you 
are using the same variable for both but you could include more values in 
the hash at the end to be used in your query.
 

On Wednesday, July 16, 2014 3:00:08 PM UTC-6, Ruby-Forum.com User wrote:

 I am new to RoR and I am trying to convert one of my old PHP 
 applications into RoR. 

 However, I am not having any luck finding out how to do an OR statement 
 in RoR. My old statement in PHP is as follows... 

 SELECT * FROM games WHERE home_team = {param} or away_team = {param} 
 ORDER BY game_date ASC 

 I can do the OR in the model but I can't find a way to pass the param 
 through. 

 I can pass the param in the controller but I can't find an OR statement 
 that will work. 

 I have also tried putting multiple statements together in the controller 
 but then I can't order them the way I want... 

 @home = Game.sorted.where(:home_team = params[:id]) 
 @visitor = Game.sorted.where(:away_team = params[:id]) 
 @games = @home + @visitors 
 #@games is what I refer to in the games.html.erb page but it sorts the 
 home games and then the visitor games so they aren't in order. 

 There has to be a way to do this. What am I missing? 


 Thanks 
 Mike 

 -- 
 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/e4e5d4ed-e2e1-403f-80e2-4681eb305813%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Upload UTF-8 encoded textfile

2014-07-15 Thread Eric Saupe
Gotcha. Is the file actually opened when the controller is entered? (That's 
an honest question I'm interested in how that works coming as an upload 
from a form) The way you've described, that I failed to understand the 
first time, to me seems like the best way but I'd be interested to see what 
others have to say.

Sorry I couldn't be of more help.

On Tuesday, July 15, 2014 5:47:57 AM UTC-6, Ruby-Forum.com User wrote:

 In this case, it is pretty certain that ever file will contain UTF-8 
 characters, and in general, I think the cases are few where we can 
 assume input to be represented by 7-bit-ASCII. 

 What I do not know for sure is whether or not the file will have a BOM, 
 but I think Ruby can figure this out automatically, when supplying the 
 BOM option on opening. 

 It would make sense to allow also file using different encoding, such as 
 UTF-16, but this is something I will have to deal with later. 

 The stackoverflow link you presented, doesn't really answer my problem 
 though. It just describes how I can *open* an UTF-8 file, and this is 
 the workaround I'm using meanwhile (as outlined in my posting where I 
 say: I could create a File object by opening. 

 What I would like to know is, whether there is a simpler way (since the 
 file, after all, is already opened when my controller is entered), and 
 in particular why set_encoding doesn't work for  my Tempfile object, 
 even though this would work well for a File object. 

 -- 
 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/3a88144c-8e87-4744-9302-e87d866806a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Re: cannot connect to local host

2014-07-14 Thread Eric Saupe
Hassan is right. I doubt the problem is with your Gemfile.lock so I suggest 
starting elsewhere and leaving it alone.

The best thing would be to stash your changes using git and going back to a 
working version of the application. Go back to the last version that worked 
and see what's different. Alternatively you can keep your current changes 
and just figure out what is happening with `place'. Search your files and 
make sure that everything is fine around that variable. It's clear the 
problem is with that so make sure that every instance of that variable is 
working and that should fix the problem that appears with the imports as 
well.

On Monday, July 14, 2014 10:26:14 AM UTC-6, Hassan Schroeder wrote:

 On Mon, Jul 14, 2014 at 9:06 AM, Rasool SB raso...@gmail.com 
 javascript: wrote: 

  When ever we accidentally shutdown, Rails or Ruby files( temporary 
  files) like /tmp/pids/server.pid  and or Gemfile.lock caches logs to 
  interact with some methods, classes etc., due to sudden close of the 
  application when we try to run rails s it checks your gemfile.lock to 
 load 
  the gems in to your environment, so the Gemfile.lock can't give right 
  information due to sudden close. 

 WAT?? If a Gemfile.lock was changed at runtime, it would show up in 
 a `git status` after every invocation of the server. So -- no. 

  By deleting the Gemfile.lock wont harm anything (it's kind of temp 
 file) 
  by running bundle install you will get the Gemfile.lock file 
  automatically when the bundle install finishes. 

 It's in no way a kind of temp file. 

 Yes, you'll get a new Gemfile.lock running `bundle install`, but it won't 
 necessarily match the previous one unless you have explicit versions 
 set for each gem in the Gemfile. 

 Deleting Gemfile.lock and re-bundling is a great way to muddy the 
 water when your app is already broken. Why would you want that? 

 -- 
 Hassan Schroeder  hassan.s...@gmail.com 
 javascript: 
 http://about.me/hassanschroeder 
 twitter: @hassan 


-- 
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/da6f02de-2eba-443d-a0a3-5812c7098d3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: Upload UTF-8 encoded textfile

2014-07-14 Thread Eric Saupe
Maybe try 
this? 
http://stackoverflow.com/questions/5163339/write-and-read-a-file-with-utf-8-encoding
Does it matter if every file is considered UTF-8 even if it never contains 
a UTF-8 character?

On Monday, July 14, 2014 5:01:11 AM UTC-6, Ruby-Forum.com User wrote:

 My Rails application (Rails 4.1, Ruby 2.1.1) offers the user to upload a 
 file. This file will then be parsed by the application, and after the 
 parsing is done, it is deleted from the upload area. 

 So far, I have the following: 

 In my upload form, I have 

 %= file_field_tag :upload, {accept: 'text/plain', class: 
 'file_upload'} % 

 In my controller, params[:upload] contains an object of class Tempfile, 
 which is already opened for reading. I am using #readline to read 
 through this file. 

 The problem now is that the file has encoding utf-8, and as soon as 
 reading contains a character which isn't also a 7-Bit ASCII character, I 
 get an exception. 

 What is the best way to read an uploaded UTF-8 file? 

 I was already thinking along the following line: The Tempfile class also 
 has a method #path, which returns the path of the uploaded file. I could 
 create a File object by opening this path, specify utf8 when opening it, 
 and read from this. 

 However, since this problem must occur quite frequently, I wonder 
 whether there is a way (maybe in the file_field_tag) to tell Rails that 
 the Tempfile object should be opened as utf8 for reading. Is this 
 possible, or is there another good way to deal with this problem? 

 -- 
 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/c9aad9ce-0926-47c1-ac1f-64e8247594dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: layout rendering problem

2014-07-14 Thread Eric Saupe
Because you have /layouts inside of /welcome it would need to be %= render 
'welcome/layouts/login' % and I think you'll also need an underscore 
before login.html.haml to make it _login.html.haml because it's a partial.

On Sunday, July 13, 2014 5:45:39 AM UTC-6, Roelof Wobben wrote:

 Hello, 

 I have this directory layout.

 app/views 

 - welcome 
  index.html.haml 
 --- layouts 
 -- login.html.haml 

 So to use the login.html.haml I thought this would work. 

 Contents of welcome/index.html 

 = render 'layouts/login' 

 But still I see a template missing error message.

 How to solve this ?

 Roelof



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


[Rails] Re: how to make this form

2014-07-14 Thread Eric Saupe
%= form_for @user do |f| %
  div class=field
%= f.label :login_naam %:
%= f.text_field :login_naam, class: login, placeholder: login naam 
%br /
  /div

  %= f.submit %
% end %

You'll want to let Rails take care of the id's so they can match up the 
label with the field automatically as well as the name variable.

Take a read through http://www.railstutorial.org/book to get an idea of 
creating a simple application with all the of the basic building blocks 
explained.

On Monday, July 14, 2014 1:34:08 PM UTC-6, Roelof Wobben wrote:

 Hello, 

 I have read several pages but I cannot find how to make a form with this 
 field ; 

 div class=field
 label for=Login naam Login naam:/label
 input type=text id=firstname name=firstname 
 value= placeholder=login naam class=login /
 /div !-- /field --

 Can anyone give me a hint ?

 Roelof



-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+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/25bc86bb-0044-49d4-8d38-d52e61993f9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] STI where inheritance column values are not the same as the name of the class

2014-07-10 Thread Eric Roberts


I recently tried to retrofit STI on a database table that had already 
existed for a while. Here's a basic outline of the scenario.

   1. I had a class 'Code' and a database table 'codes'.
   2. 'Code' had an attribute 'units', which could be either '$' or '%'
   3. I wanted the STI classes to be Code::Dollar or Code::Percent

I successfully implemented this with the following:

class Code
  self.inheritance_column = 'units'

  class  self
def find_sti_class(units)
  unit_class_for[units]
end

def sti_name
  unit_class_for.invert[self]
end

def unit_class_for
  {
'$' = Code::Dollar,
'%' = Code::Percent
  }
end
  end
end

This works perfectly if I use it in the following way:

Code::Dollar.new(initialization_hash)
Code::Percent.new(initialization_hash)

However, if I do just Code.new(units: '$') or something.build(units: '$'), 
I get an error like the following:

ActiveRecord::SubclassNotFound: Invalid single-table inheritance type: $ is not 
a subclass of Code

What I really want is for Code.new(units: '$') to return me a Code::Dollar
 object.

I was able to trace the lookup of the class name into
ActiveRecord::Inheritance::ClassMethods#subclass_from_attrs. From there I 
could see that it was trying to build the class name from the units value 
in the database, which obviously doesn't work as there isn't a class named 
$ or %.

What I'm really trying to do is setup STI to work correctly when the value 
of the database column doesn't correspond to a class name. As there is 
already another method called find_sti_class, it seems curious that we 
couldn't use it inside of subclass_from_attrs in order to make it work in 
this way. I did try it and was successful, but as find_sti_class is a 
private method, I did not submit a patch using this.

So, after all of that, I guess what I'm after is finding out if doing such 
a thing is possible in Rails as is. If not, would a patch to make it 
possible be desired by people other than myself? And if that patch made 
find_sti_class part of the public interface, would that be likely to be 
accepted?

-- 
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/8af5104b-6e67-4dae-8e63-63216dcddccf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: SPECIALS RELATIONSHIP!?

2014-05-30 Thread Simon Eric
I resolved that problem.

I done somethig like so to update each column:

def update_multiple
 @postis = Posti.find(params[:posti_ids])

 @postis.each do |posti|
  posti.update_column(:stato, params[:posti])
   end
 redirect_to prenotazione_path(params[:spectacle_id])
   end

%= form_for :posti, :url = update_multiple_path, :html = { :method = 
:put } do |f| %
%= hidden_field_tag spectacle_id, params[:spectacle_id] %
  strongPosti scelti:/strong
 ul
  % for posti in @postis %
  li
 %=h posti.numero %

%= hidden_field_tag posti_ids[], posti.id %
  /li
  % end %
/ul

  p

%= f.hidden_field :stato, :value = checked %
  /p
  p%= f.submit PRENOTA %/p
% end %

It works very well and i am so very happy. Thank you Colin for helps. I 
will very well a tutorial when i will finish all my esams at university. 
Ruby on Rails is the best :)

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


[Rails] SPECIALS RELATIONSHIP!?

2014-05-28 Thread Simon Eric
i want to associate one model with 4 models. For example i call a first
model Spectacle and call others Hall1, Hall2, Hall3 and Hall4.  All of
Halls have the same attributes: id and seat.  Each Hall have 10 seats.
I  want to create an spectacle on the database and associate it with any
Hall.
Problems:
How can i do this association in rails?
It is possible to do this type of association?
How can i get all of Hall's seats  through spectacle that i created?

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


[Rails] Re: SPECIALS RELATIONSHIP!?

2014-05-28 Thread Simon Eric
Thank you very much Jesse!

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


[Rails] Re: SPECIALS RELATIONSHIP!?

2014-05-28 Thread Simon Eric
Thank you very much Colin. I will try that :)

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


[Rails] Re: SPECIALS RELATIONSHIP!?

2014-05-28 Thread Simon Eric
Colin i try what you tell me. It work find. Thank very much.
The next step is that: if an user choice the seat on the hall, it must
not be appear againt on the view.

I have some view like this:

%= form_tag( riepilogo_path, method: post, id: sel) do %

%= hidden_field_tag sala, params[:sala] %
  %= hidden_field_tag spectacle_id, params[:spectacle_id] %

  %= hidden_field_tag num, params[:num] %
table
  tr
th/th
thNumero/th

  /tr
% for posti in @postis %
  tr
td%= check_box_tag posti_ids[], posti.id %/td
td%=h posti.numero %/td

  /tr
% end %
/table
%= submit_tag OK, id: sub%
% end %

controller of Postis is something like so:

class PostisController  ApplicationController
 def index
@postis = Posti.where(:stato = unchecked , :spectacle_id =
params[:spectacle_id] , :hall_num = params[:sala])
  end

def posti_multiple
@postis = Posti.find(params[:posti_ids])

   end
end

In the Posti's model i have attributes: spectacle_id, hall_num,
seat(integer) and stato (:default = unchecked).

An user choice her seat on the hall. When he submit the form, seats be
load in posti_ids[]. I want to update stato of seats wich are present in
posti_ids from unchecked to checked on the database. How can do
that. Thank you very much

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

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


[Rails] Re: Re: SPECIALS RELATIONSHIP!?

2014-05-28 Thread Simon Eric
Please i try this:
@postis.update_column(stato: checked)
but i have error like so:
undefined method `update_column' for #Array:0xb7a50e8

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


[Rails] Re: Re: Re: SPECIALS RELATIONSHIP!?

2014-05-28 Thread Simon Eric
@postis is an string.

Now i see where i the problem. I fix them like so:
def posti_multiple
@postis = Posti.find(params[:posti_ids])
 a=Posti.find_by(numero: params[:posti_ids])
   a.update_column(:stato, checked)

end

When i have  for example posti_ids[ any number], one seat disappear on 
the view. When i have posti_ids[any number, any number, ... ], one 
seat also desappear but i don't want that. All of seat wich are choice 
must be disappear. I think i can do some loop??

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


[Rails] How can I convert an ImageMagick shell script for use in my RoR project?

2014-04-09 Thread Eric Kornmeyer
I'm creating a project that lets users upload images onto products and
then buy the products. I'm using Carrierwave and Minimagick. I found
this cylnderize script on fmwconcepts. It's a shell script. It is
literally perfect for what I need as a lot of the products are mugs.
Does anyone know how I might be able to convert the script into
minimagick code I can use in my controller?

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


[Rails] Re: How can I convert an ImageMagick shell script for use in my RoR project?

2014-04-09 Thread Eric Kornmeyer
Lol that doesn't wrap an image around a cylinder thanks though

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


[Rails] Re: Web App looking for a new business model

2014-03-03 Thread Eric Palumbo
apps for sale great prices will take offers too

https://www.apptopia.com/listings/7043-2-photo-editing-apps-with-iap-and-ads-one-free-one-paid-for-a-lot-of-potential
https://www.apptopia.com/listings/7032-1000-downloads-unblock-me-game-with-trucks-ads-and-iap
https://www.apptopia.com/listings/7014-500-downloads-first-day-full-reskined-app-with-license-and-iap-and-ads-needs-marketing
https://www.apptopia.com/listings/6557-two-apps-quick-sale-multiplayer-or-single-player-racing-game

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


[Rails] Re: Best way to securely connect to remote Postgres server from Rails.

2014-02-20 Thread Eric Hayes
Thanks for your insight, Rick. I am the server provider :)



On Sunday, February 16, 2014 4:56:32 PM UTC-8, Rick wrote:



 On Saturday, February 15, 2014 4:46:54 PM UTC-5, Eric Hayes wrote:


 I'm wonder how most people securely connect to a Postgres database on a 
 server separate from the app server.

 The ActiveRecord docs for a MySQL connection have explicit SSL options, 
 whereas with Postgres it seems one would pass SSL options as documented for 
 libpq.

 However a quick Googling returns SO threads with suggestions to use SSH 
 tunnels. Which I guess could be managed with something like AutoSSH.

 I'd love to hear from anyone with experience with this. Is one method 
 faster than the other, or easier to maintain? —Thanks!


 If your remote PostgreSQL server has ssl capability compiled in (look for 
 Secure TCP/IP Connections with SSL in the PostgreSQL docs), this would be 
 the preferred way to go. The connection status is visible to your app 
 because the secure channel is established between libpg and the remote 
 host. Running through an SSH tunnel has the added baggage of startup and 
 health monitoring, along with a restart policy as required. There may also 
 be a run time penalty (not sure on this one) on communication cost. In 
 either case, you want to use an MD5 password to establish the connection to 
 the server.

 You should probably get familiar with the normal PostgreSQL options and 
 start a conversation with your server provider.

 Rick


-- 
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/b371a3e8-25f5-4284-aeec-68fa5a561371%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] Update 'strong_parameters' from 0.1.4 to 0.2.3

2014-02-16 Thread Eric Jefcoat
Hello,

Can anyone tell me how to upgrade 'strong_parameters' from 0.1.4 to 0.2.3 
on the Terminal? When I use 'update strong_parameters' it tell me that it 
no longer uses update. When I say upgrade it says command not found.  I am 
using RVM.

Thank you so much for your help,
Eric

-- 
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/71615d9c-4cf9-48ad-b43d-f7879ff83159%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] RVM group in Terminal

2014-02-16 Thread Eric Jefcoat
Hello,

I need to fix some RVM permissions. How do I make sure I'm in the RVM group 
in the Terminal?

Thank you for your help,
Eric

-- 
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/ca82263c-ee46-4e5a-8992-b90dda3a2b12%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] Re: RVM group in Terminal

2014-02-16 Thread Eric Jefcoat
When I try to fix permissions, with 'rvm fix-permissions' it tells me that 
it's fixing them in 'users/group'. I need to fix them in the rvm group but 
don't know how to fix them IN the rvm group.

Thank you for your help,
Eric

On Sunday, February 16, 2014 9:44:55 PM UTC-7, Eric Jefcoat wrote:

 Hello,

 I need to fix some RVM permissions. How do I make sure I'm in the RVM 
 group in the Terminal?

 Thank you for your help,
 Eric


-- 
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/231a2089-417e-45e6-ad57-280e8b889969%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] Best way to securely connect to remote Postgres server from Rails.

2014-02-15 Thread Eric Hayes

I'm wonder how most people securely connect to a Postgres database on a 
server separate from the app server.

The ActiveRecord docs for a MySQL connection have explicit SSL options, 
whereas with Postgres it seems one would pass SSL options as documented for 
libpq.

However a quick Googling returns SO threads with suggestions to use SSH 
tunnels. Which I guess could be managed with something like AutoSSH.

I'd love to hear from anyone with experience with this. Is one method 
faster than the other, or easier to maintain? —Thanks!

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


[Rails] Gem errors

2014-02-07 Thread Eric Jefcoat
Hello all,

I seem to still be getting Gem errors when trying to run 'rails server'. 
Not sure what I need to do to fix it.

Computer:treebook admin$ rails server
*/usr/local/rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/tmpdir.rb:80:in 
`mkdir': ERROR: Failed to build gem native extension. 
(Gem::Ext::BuildError)*

*Permission denied - 
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/json-1.8.1/ext/json/ext/generator/.gem.20140207-3371-uiaqx9*

Any ideas on how to fix this?

Thanks in advance for your help. 
Eric

-- 
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/7b84d791-6e3a-432d-90d4-8f42f05669fa%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] Re: Gem errors

2014-02-07 Thread Eric Jefcoat
NevermindHa! I just ran the same stuff @mpapis told me to do for a 
seperate permission error and now it seems to be running the rails server 
just fine. 

Sheesh. Sometimes the solution is right under your nose. 

Thanks anyway,
Eric

On Friday, February 7, 2014 1:24:02 PM UTC-7, Eric Jefcoat wrote:

 Hello all,

 I seem to still be getting Gem errors when trying to run 'rails server'. 
 Not sure what I need to do to fix it.

 Computer:treebook admin$ rails server
 */usr/local/rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/tmpdir.rb:80:in 
 `mkdir': ERROR: Failed to build gem native extension. 
 (Gem::Ext::BuildError)*

 *Permission denied - 
 /usr/local/rvm/gems/ruby-1.9.3-p484/gems/json-1.8.1/ext/json/ext/generator/.gem.20140207-3371-uiaqx9*

 Any ideas on how to fix this?

 Thanks in advance for your help. 
 Eric


-- 
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/53855047-4ecd-487a-8019-df704093e261%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] rbenv to RVM command equivalencies

2014-02-05 Thread Eric Jefcoat
Hello,

I need a sort of translation dictionary for rbenv to RVM commands.

I am working on some learning tracks and projects on Treehouse for RoR 
development and their tutorial calls for using rbenv. I already have RVM 
installed for the Skillshare class, Rails in 30 Days. I received some great 
help on this forum in getting my permissions straightened away in RVM, and 
I don't want to just uninstall it to install rbenv. I don't have any 
problem with rbenv. I would just like to keep RVM since it's now installed 
properly and it worked great on my previous project.

I have searched for RVM and rbenv equivalent commands, and have struck out 
on stuff that would help me understand when Treehouse says this for rbenv, 
you do this for RVM. Any ideas how I get that help?

My thanks to anyone who can help!
Eric

-- 
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/0d92b607-2c1b-4085-b802-df775d29f339%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] Re: Trouble with RVM permissions when executing a command line 'bundle install'

2014-01-30 Thread Eric Jefcoat
Fred,

How do I go about removing rvm? I don't remember setting up a root user 
password on my computer, When I search Spotlight for rvm, I get some 
other gem and ruby folders it looks like, but not something named rvm. 

Thanks for your help,
Eric

On Thursday, January 30, 2014 3:08:16 AM UTC-7, Frederick Cheung wrote:



 On Thursday, January 30, 2014 5:41:59 AM UTC, Eric Jefcoat wrote:


 ERROR: While executing gem ... (Gem::FilePermissionError)
 You don't have write permissions into the 
 /usr/local/rvm/gems/ruby-1.9.3-p392 directory.

 That looks like a systemwide install of rvm - normally the rvm folder is 
 in your home folder so that there are no permission problems. I'd be very 
 tempted to remove rvm and reinstall it (when you install rvm, don't use 
 sudo - just install it as your regular user)

 Fred
  

 


 
  



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


[Rails] Re: Trouble with RVM permissions when executing a command line 'bundle install'

2014-01-30 Thread Eric Jefcoat
Michael,

Thank you for helping. I followed your directions to fix the permissions, 
and I was able to run the bundle install, without errors! 

You are the man!! Thank you so much!
Eric

computer:crumblr admin$ rails server
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in
 
`to_specs': Could not find railties (= 0) amongst [i18n-0.6.9, 
minitest-4.7.5, multi_json-1.8.4, rake-10.1.1] (Gem::LoadError)
from 
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in
 
`to_spec'
from 
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems.rb:1231:in
 
`gem'
from /usr/local/rvm/gems/ruby-1.9.3-p392/bin/rails:18:in `main'
from /usr/local/rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in 
`eval'
from /usr/local/rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in 
`main'


On Thursday, January 30, 2014 6:41:44 AM UTC-7, Michał Papis wrote:

 You have two options:

 1) fix the permissions:

 - make sure you are in rvm group, run id and there should be group rvm 
 - if it is not there run: rvm group add rvm $USER
 - make sure that rvm is up to date and has properly set permissions: rvm 
 get stable; rvm fix-permissions
 - restart your computer - it might be required to apply permission changes 
 and to properly load your environment

 2) uninstall system rvm and install it in home:

 - run: sudo rm -rf /etc/profile.d/rvm.sh /etc/rvmrc /usr/local/rvm 
 $HOME/.rvm*
 - make sure your environment is empty of old rvm, run env | grep rvm if 
 it is empty it's all fine, if not - restart computer to ensure your 
 environment is reset
 - install rvm: \curl -L https://get.rvm.io | bash -s stable
 - follow the installation instructions and install ruby: rvm install ruby



-- 
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/ed8dbe3e-9c83-4c1a-b3ed-c1fa6d37b7a2%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] Trouble with RVM permissions when executing a command line 'bundle install'

2014-01-29 Thread Eric Jefcoat
Hello,

I heard from 37signals that this is where the go to people hang out for Ruby on 
Rails. I included a full screenshot of my Terminal interaction, as well as a 
brief explanation below. 

I am taking a Ruby on Rails class on Skillshare.com. It's a great class, but 
I'm just learning programming. RoR is starting to make some sense to me, but I 
am having trouble with the final lesson, which is getting it online. I've asked 
our class and instructor (who is very good, no disrespect) for help and haven't 
been able to solve it yet. I'm begging for someone to help me.

I'm on a Macbook running 10.7x. When I run 'bundle install', from the command 
line, it starts 'Fetching data...' and 'Resolving dependencies.' 

Then after it says Using multi_json (1.8.4), I get this error:

=
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native 
extension.

/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb 
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.



An error occurred while installing atomic (1.1.14), and Bundler cannot continue.
Make sure that `gem install atomic -v '1.1.14'` succeeds before bundling.


ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/local/rvm/gems/ruby-1.9.3-p392 
directory.



Any help would be great. I have installed XCODE v.4.6.3 (which is the latest 
for OS 10.7x) and the development tools that go with it, but still get the same 
error message.

BTW,
I am using the command line from the administrator account, but I previously 
installed RoR on my personal account on the computer. So I don't know if it's 
trying to access those files when doing the bundle install, but I thought it 
was worth mentioning.

Thanks in advance to anyone willing to help,

Eric


 

-- 
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/a33cd0f5-8986-4dcd-93bb-a678d53706c6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] Ruby On Rails Getting Started question

2013-12-03 Thread Eric Blow
Hi All,
 I am going through the getting started guide here 
http://guides.rubyonrails.org/getting_started.html
And in section 5.7 it refers to a code snippet that I don't understand what 
to do with it.
post GET/posts/:id(.:format)  posts#show
 
I don't understand if I am supposed to put this code somewhere or not. The 
guide doesn't tell me exactly. 
I also noticed the same sort of code is discussed in section 5.8 where it 
mentions 
posts GET/posts(.:format)  posts#index
Any help would be great.

Thanks!

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


[Rails] Re: Retrieve duration (in string format) from database and convert to Ruby syntax for calculation

2013-09-20 Thread Eric Hayes
Take a look at this gem: https://github.com/peleteiro/ruby-duration
—it will convert an arbitrary duration (like 1 month, 2 weeks, etc.) into 
seconds which can be stored in the DB. It is very similar to what Raj is 
recommending, just a little more formal. Either way you can avoid eval'ing 
code, and your calculation can be a lot more flexible.

On Friday, September 20, 2013 12:30:16 AM UTC-7, Fai Wong wrote:

 If I store 1.month as a string in the database, how do I convert 1.month 
 into 1.month?

 This way I can use the 1.month value stored in database to perform the 
 following calculation.

 Time.now + 1.month 


-- 
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/bd968e41-7f42-4ca0-91ba-a608b4a75955%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] Re: How to increase the css and js file loading speed in rails 3

2013-09-20 Thread Eric Hayes
Without the Asset Pipeline, the answer is to send less CSS or JS. With JS 
you could move as much as possible to the bottom of your HTML and include 
as few files as possible.

On Friday, September 20, 2013 4:49:54 AM UTC-7, chandra sekar wrote:

 Hi All

 Right now i am working on rails 3 . Is there any possible way to increase 
 the css and js file loading speed (with out asset). please help me



 Regards
 Chandrashekar


-- 
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/1842098a-2364-4ec2-829e-46d3f242efed%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Rails] 3.2.13 breaks localized ActiveScaffold assets compilation

2013-03-19 Thread Yves-Eric
Hi Jeffrey,


Awesome, that fixed it, thanks! 


For anyone facing this issue, the fix is not released yet, so bundle 
update active_scaffold won't do. You need this:

gem active_scaffold, :git = 
git://github.com/activescaffold/active_scaffold.git, :tag = = 
v3.3.0.rc3


Thanks again,
Yves-Eric


On Tuesday, 19 March 2013 12:08:33 UTC+9, Jeffrey Jones wrote:

 Actually after a bit of research it looks like this was fixed in the 
 below commit 


 https://github.com/activescaffold/active_scaffold/commit/2536a29a1d21469278c95b7f2a87deba14040be6
  

 to fix this issue 

 https://github.com/activescaffold/active_scaffold/issues/249 

 Cheers 

 Jeff 

 On 19/03/13 11:58, Yves-Eric wrote: 
  Hi, 
  
  
  I just tried upgrading to 3.2.13 a project that worked fine under 
 3.2.12, 
  but that broke our assets pipeline compilation. It looks like 
 compilation 
  now chokes on ActiveScaffold asset 'date_picker_bridge.js.erb'. 
  (Full stack trace below). 
  
  The first line of that file is: 
  
  %= ActiveScaffold::Bridges[:date_picker].localization % 
  
  And we use Japanese locale. 
  
  
  
  How can we fix this? 
  
  
  Thank you, 
  Yves-Eric 
  
  
  
  $ rake --trace assets:precompile 
  ** Invoke assets:precompile (first_time) 
  ** Execute assets:precompile 
  /Users/DEV/.rvm/rubies/ruby-1.9.3-p327-perf/bin/ruby ./bin/rake 
  assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace 
  ** Invoke assets:precompile:all (first_time) 
  ** Invoke assets:cache:clean (first_time) 
  ** Invoke assets:environment (first_time) 
  ** Execute assets:environment 
  ** Invoke environment (first_time)' 
  ** Execute environment 
  ** Execute assets:cache:clean 
  ** Execute assets:precompile:all 
  rake aborted! 
  invalid byte sequence in US-ASCII 
(in 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/bundler/gems/active_scaffold-2053b21e43e6/app/assets/javascripts/jquery/date_picker_bridge.js.erb)
  

  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/safety_colons.rb:20:in
  

  `evaluate' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/tilt-1.3.6/lib/tilt/template.rb:77:in
  

  `render' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in
  

  `block in evaluate' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in
  

  `each' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in
  

  `evaluate' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/unprocessed_asset.rb:14:in
  

  `initialize' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/base.rb:16:in
  

  `new' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/base.rb:16:in
  

  `block in build_asset' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in
  

  `circular_call_protection' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/base.rb:14:in
  

  `build_asset' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in
  

  `block in build_asset' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in
  

  `cache_asset' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in
  

  `build_asset' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in
  

  `find_asset' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/index.rb:14:in
  

  `find_asset' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/asset_with_dependencies.rb:91:in
  

  `block in build_required_assets' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/asset_with_dependencies.rb:85:in
  

  `each' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/asset_with_dependencies.rb:85:in
  

  `build_required_assets' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/unprocessed_asset.rb:27:in
  

  `initialize' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/base.rb:16:in
  

  `new' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/base.rb:16:in
  

  `block in build_asset' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in
  

  `circular_call_protection' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo

Re: [Rails] 3.2.13 breaks localized ActiveScaffold assets compilation

2013-03-19 Thread Yves-Eric
I managed to typo that line! For some weird reason it worked, but I noticed 
an error in a project that uses packaged gems... Of course there should not 
be a = inside the tag! The correct declaration is:

gem active_scaffold, :git = git://
github.com/activescaffold/active_scaffold.git, :tag = v3.3.0.rc3



On Tuesday, 19 March 2013 15:59:07 UTC+9, Yves-Eric wrote:

 Hi Jeffrey,


 Awesome, that fixed it, thanks! 


 For anyone facing this issue, the fix is not released yet, so bundle 
 update active_scaffold won't do. You need this:

 gem active_scaffold, :git = git://
 github.com/activescaffold/active_scaffold.git, :tag = = v3.3.0.rc3


 Thanks again,
 Yves-Eric


 On Tuesday, 19 March 2013 12:08:33 UTC+9, Jeffrey Jones wrote:

 Actually after a bit of research it looks like this was fixed in the 
 below commit 


 https://github.com/activescaffold/active_scaffold/commit/2536a29a1d21469278c95b7f2a87deba14040be6
  

 to fix this issue 

 https://github.com/activescaffold/active_scaffold/issues/249 

 Cheers 

 Jeff 

 On 19/03/13 11:58, Yves-Eric wrote: 
  Hi, 
  
  
  I just tried upgrading to 3.2.13 a project that worked fine under 
 3.2.12, 
  but that broke our assets pipeline compilation. It looks like 
 compilation 
  now chokes on ActiveScaffold asset 'date_picker_bridge.js.erb'. 
  (Full stack trace below). 
  
  The first line of that file is: 
  
  %= ActiveScaffold::Bridges[:date_picker].localization % 
  
  And we use Japanese locale. 
  
  
  
  How can we fix this? 
  
  
  Thank you, 
  Yves-Eric 
  
  
  
  $ rake --trace assets:precompile 
  ** Invoke assets:precompile (first_time) 
  ** Execute assets:precompile 
  /Users/DEV/.rvm/rubies/ruby-1.9.3-p327-perf/bin/ruby ./bin/rake 
  assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace 
  ** Invoke assets:precompile:all (first_time) 
  ** Invoke assets:cache:clean (first_time) 
  ** Invoke assets:environment (first_time) 
  ** Execute assets:environment 
  ** Invoke environment (first_time)' 
  ** Execute environment 
  ** Execute assets:cache:clean 
  ** Execute assets:precompile:all 
  rake aborted! 
  invalid byte sequence in US-ASCII 
(in 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/bundler/gems/active_scaffold-2053b21e43e6/app/assets/javascripts/jquery/date_picker_bridge.js.erb)
  

  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/safety_colons.rb:20:in
  

  `evaluate' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/tilt-1.3.6/lib/tilt/template.rb:77:in
  

  `render' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in
  

  `block in evaluate' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in
  

  `each' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in
  

  `evaluate' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/unprocessed_asset.rb:14:in
  

  `initialize' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/base.rb:16:in
  

  `new' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/base.rb:16:in
  

  `block in build_asset' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in
  

  `circular_call_protection' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/base.rb:14:in
  

  `build_asset' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in
  

  `block in build_asset' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in
  

  `cache_asset' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in
  

  `build_asset' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in
  

  `find_asset' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/index.rb:14:in
  

  `find_asset' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/asset_with_dependencies.rb:91:in
  

  `block in build_required_assets' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/asset_with_dependencies.rb:85:in
  

  `each' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/asset_with_dependencies.rb:85:in
  

  `build_required_assets' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/unprocessed_asset.rb:27:in
  

  `initialize' 
  
 /Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides

[Rails] 3.2.13 breaks localized ActiveScaffold assets compilation

2013-03-18 Thread Yves-Eric
Hi,


I just tried upgrading to 3.2.13 a project that worked fine under 3.2.12,
but that broke our assets pipeline compilation. It looks like compilation
now chokes on ActiveScaffold asset 'date_picker_bridge.js.erb'.
(Full stack trace below).

The first line of that file is:

%= ActiveScaffold::Bridges[:date_picker].localization %

And we use Japanese locale.



How can we fix this?


Thank you,
Yves-Eric



$ rake --trace assets:precompile
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/DEV/.rvm/rubies/ruby-1.9.3-p327-perf/bin/ruby ./bin/rake 
assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Invoke assets:cache:clean (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)'
** Execute environment
** Execute assets:cache:clean
** Execute assets:precompile:all
rake aborted!
invalid byte sequence in US-ASCII
  (in 
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/bundler/gems/active_scaffold-2053b21e43e6/app/assets/javascripts/jquery/date_picker_bridge.js.erb)
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/safety_colons.rb:20:in
 
`evaluate'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/tilt-1.3.6/lib/tilt/template.rb:77:in
 
`render'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in
 
`block in evaluate'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in
 
`each'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in
 
`evaluate'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/unprocessed_asset.rb:14:in
 
`initialize'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/base.rb:16:in
 
`new'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/base.rb:16:in
 
`block in build_asset'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in
 
`circular_call_protection'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/base.rb:14:in
 
`build_asset'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in
 
`block in build_asset'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in
 
`cache_asset'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in
 
`build_asset'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in
 
`find_asset'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/index.rb:14:in
 
`find_asset'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/asset_with_dependencies.rb:91:in
 
`block in build_required_assets'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/asset_with_dependencies.rb:85:in
 
`each'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/asset_with_dependencies.rb:85:in
 
`build_required_assets'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/unprocessed_asset.rb:27:in
 
`initialize'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/base.rb:16:in
 
`new'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/base.rb:16:in
 
`block in build_asset'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in
 
`circular_call_protection'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/base.rb:14:in
 
`build_asset'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in
 
`block in build_asset'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in
 
`cache_asset'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in
 
`build_asset'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in
 
`find_asset'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/turbo-sprockets/sprockets_overrides/index.rb:14:in
 
`find_asset'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/asset_with_dependencies.rb:91:in
 
`block in build_required_assets'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf/gems/turbo-sprockets-rails3-0.3.6/lib/sprockets/asset_with_dependencies.rb:85:in
 
`each'
/Users/DEV/.rvm/gems/ruby-1.9.3-p327-perf

[Rails] tfs api from rails

2012-04-18 Thread Eric Stockbridge
does anyone have an idea if there is a way to make calls to the TFS api
from a rails app?
i think i saw something about team system web access having a soap api
that you can use.

the reason i ask is I am creating a web ap at work for us to use and we
want to be able to add work items to tis and track work items in tis to
update certain things in our app when they change, and I would rather
use rails than asp.net mvc if i can. so i was wondering if anyone else
has done this before

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

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



[Rails] Re: New to Ruby on Rails - Assigning variation (like size or color) to products

2012-02-25 Thread Eric L.
Top 3 book for Rails/Ruby Development

1. The Ruby Programming Language by David Flanagan   Yukihiro Matsumoto
  or
1. Programming Ruby 1.9 (3rd edition): The Pragmatic Programmers' Guide 
by by Dave Thomas,  with Chad Fowler and Andy Hunt


2. The Rails Way by Obie Fernandez

3. Beginning Ruby: From Novice to Professional by Peter Cooper


Also check codeschool.com they have a free ruby and free rails course, 
railscasts.com has many free higher level rails screencast  
guides.rubyonrails.org has several rails guides

If you are new to programming in general then try searching for 
information regarding
Object-oriented programming

if I understand you correctly just create a size variable for the 
product model or (this is where oop comes in) create a tshirt class 
which would inherit from the product class and give the tshirt class a 
size variable to be customized in the view.


Hope this all helps

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

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



[Rails] Database Issue

2011-12-06 Thread Eric B.
So I'm having an interesting issue with my database and associations.

I have three models,  Users, Groups, and Roles.  They are connected via
a join table that has user_id, group_id, and role_id on the same table.
A user is in a group, with a role.  The same user can be in another
group with another (or the same) role.

So, the user model has a has_and_belongs_to_many :roles, and the role
model has a has_and_belongs_to_many :users, with the appropriate tags to
make it work.

With this, @user.roles will grab a list of all roles associated with
that user, and @role.users will grab all the users that have that role.
Duplicates are possible.

One interesting behavior, was that, if the user and the role model both
had a group_id column, then when @user.roles was called (and likewise
@role.users), it would grab the group_id from the join_table for each
role, instead of the group_id from users or roles.  If I take out the
group_id from users and roles, then it does not appear when I call
@user.roles

This behavior is desirable, because then it lets me do things like,

@user.roles[@user.roles.index{|x| x.group_id==1}].name

to get the name of the role that the user has in group 1.  Things like
that.

So my question is, how can I get that functionality (grabbing the
group_id when going through the join table) without the group_id columns
in the user and role tables?

I've tried declaring group_id as attr_accessor :group_id for both user
and role, but that didn't work.

The most important thing is being able to maintain the behavior, that I
can call @user.roles[0].group_id, and @roles.user[0].group_id, with
group_id being grabbed from the join table.  Any way to do that would
solve my problem.

Is there a way I can do it with definitions?  like def
self.Role.group_id or something like that?

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

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



[Rails] Optional Dynamic Prepended Route via scope

2011-10-05 Thread Eric Helms
Hello,

Say I have the following in my routes file:

scope (/:organization) do
  resources :systems, :except = [:destroy] do
member do
  get :packages
end
  end
end

  resources :dashboard do
collection do
  get :notices
  end

The organization can be changed by the user and various resources such
as systems are scoped off of the organization.  So, the organization
can change dynamically and so as to be restful we want to prepend the
organization to each route within that scope.  Following the Rails
guides, I attempted to use:

default_url_options()
  { :organization = current_organization.name }
end

Which generated URLs in the way desired, e.g. /Organization1/system/
However, the URLs generated (via _path() calls, e.g. dashboard_path())
include the extra paramter ?organization=Organization1 which is not
the behavior desired for this application.

My question then is - is it possible to have the organization set and
included for only those routes that declare a scope of /:organization.

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



Re: [Rails] Best Rails install for production.

2011-08-18 Thread Eric Björkvall
apache + mod_fcgi - I get better performance than when I tried apache/passenger 
and apache/mongrel.

I'm running this set up under FreeBSD, CentOS 5.x and Mac OS X 10.6

Can be a bit tricky to set up..

Cheers,
Eric

On 14 aug 2011, at 12:45, Frederick Cheung wrote:

 
 
 On Aug 14, 10:33 am, Yaroslav Govorunov govoru...@gmail.com wrote:
 Hello!
 
 Which Ruby on Rails installation scenario is the best for performance
 and durability in production:
 - Ubunthu + Apache + Passanger
 - Ubunthu + Nginx + Unicorn
 - Ubunthu + Apache + Mongrel
 - Any other option?
 
 
 Well you've also got nginx + passenger. If you move to jruby then you
 get a bunch of other deploy options too.
 Personally I'm very happy with apache + passenger.
 
 Fred
 And could someone provide links to some best practice or guidelines to
 install Rails in production?
 
 Thank you!
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to 
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/rubyonrails-talk?hl=en.
 

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



[Rails] Re: Rails, jquery and Ajax

2011-07-28 Thread Eric Björkvall
One way:

link_to #, new_comment_path, :remote = true, :id = 
new-comment-link

new.js.erb

$(#new-comment-link).hide();
$('#commentlist').html('%= render :partial = comments %')


You can use ruby logic in the .js.erb file - just like you could in 
former .rjs files.

% if @condition %
alert(condition %= @condition %);
% end %



Cheers,
Eric

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

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



Re: [Rails] Rails, jquery and Ajax

2011-07-28 Thread Eric Björkvall
One way:

link_to #, new_comment_path, :remote = true, :id = new-comment-link

new.js.erb

$(#new-comment-link).hide();
 $('#commentlist').html('%= render :partial = comments %')


You can use ruby logic in the .js.erb file - just like you could in former .rjs 
files.

% if @condition %
 alert(condition %= @condition %);
% end %



Cheers,
Eric




On 27 jul 2011, at 13:45, Paul Bergstrom wrote:

 How do I make an ajax call and then update a div with a partial? I've
 tried this but it's not working. Comment is created but the partial is
 not loaded.
 
 //view
  a href=# id=testlinkTestlink/a
  div id=commentlist
 
  /div
 
 //controller
  def new
 
  @comment = Comment.new
  @comment.save
 
  respond_to do |format|
format.html { }
format.js { }
  end
 
  end
 
 //js
 $(function() {
 
  $('#testlink').click(function() {
$.ajax({
   type: GET,
   url: /comments/new,
   success: function(){
$('#commentlist').html('%= render :partial = comments %')
 
   }
});
  });
 });
 
 -- 
 Posted via http://www.ruby-forum.com/.
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to 
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/rubyonrails-talk?hl=en.
 

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



Re: [Rails] Nature of Return Values from Search

2011-07-28 Thread Eric Björkvall
Hej

You probably  should check the params hash in the controller:

@skill_search1 = params[:skill1] etc..

Also use a debugger call in the search method to see the
parameters that are passed

def search
 debugger
 . 
 . 
end

Cheers,
Eric


On 28 jul 2011, at 22.03, Barney wrote:

 Hello,
 I'm trying the search method used in the Guides:
 http://guides.rubyonrails.org/form_helpers.html
 and I don't know what is coming back to the controller when a text box
 is empty.  When each of the 2 text boxes (described below) have a
 value then the search works.  However, if the second box is empty then
 nothing is returned, even though there is data to match the first box.
 The boxes are formed in the search.html.erb as:
 
 %= form_tag({controller = people, :action = search}, :method =
 get ) do %
  %= label_tag(:skill1, Search Skills for:) %
  %= text_field_tag(:skill1) %
  %= text_field_tag(:skill2) %
  %= submit_tag(Search) %
 % end %
 
 And are read in the controller by:
 
 def search
@people = Person.all
@skill_search1 = String.new
@skill_search1=:skill1.to_s
@skill_search2 = String.new
@skill_search2=:skill2.to_s
 
if @skill_search2.empty?
  @found_people = Person.where(skill_set LIKE ?,
 params[@skill_search1])
else
  @found_people = Person.where(skill_set LIKE ? and skill_set
 LIKE ?, params[@skill_search1],params[@skill_search2])
end
  end
 
 I have also tried: if @skill_search2  == NUL, ==   ,== nil,
 =='' and = under the theory that if you type in everything then
 something might work (hey, it's worked in the past!).
 
 Looking at the output in the command window that is used for the
 rails server call to WEBRick it seems that the second conditional
 option is always called and the statement ends in and skill_set LIKE
 ''   (that is 2 apostrophes before the final quote and, while it's a
 little hard to judge, I don't think there is a space between the
 apostrophes).
 So the question is: what is being returned by the blank text box
 and how should it be checked?
 Thanks,
Barney
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to 
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/rubyonrails-talk?hl=en.
 

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



Re: [Rails] Re: Nature of Return Values from Search

2011-07-28 Thread Eric Björkvall
Hej Barney

The debugger call will stop the execution and drop you into the debugger - it's 
not from within your text editor - it's in the
terminal window where you run your app

Start your app with 

rails server --debugger 

or (if your running rails  3.0 )

script/server --debugger


Cheers,
Eric

On 29 jul 2011, at 00.59, Barney wrote:

 Hi Eric,
 I'm using Scite and there doesn't seem to be a debugger in it.
 How else would I check that hash?
 But, could you tell me what form (type, value) is the return from
 that empty text box?
 Thanks,
  Barney
 
 
 On Jul 28, 4:59 pm, Eric Björkvall eric.bjorkv...@gmail.com wrote:
 Hej
 
 You probably  should check the params hash in the controller:
 
 @skill_search1 = params[:skill1] etc..
 
 Also use a debugger call in the search method to see the
 parameters that are passed
 
 def search
  debugger
  .
  .
 end
 
 Cheers,
 Eric
 
 On 28 jul 2011, at 22.03, Barney wrote:
 
 Hello,
 I'm trying the search method used in the Guides:
 http://guides.rubyonrails.org/form_helpers.html
 and I don't know what is coming back to the controller when a text box
 is empty.  When each of the 2 text boxes (described below) have a
 value then the search works.  However, if the second box is empty then
 nothing is returned, even though there is data to match the first box.
 The boxes are formed in the search.html.erb as:
 
 %= form_tag({controller = people, :action = search}, :method =
 get ) do %
  %= label_tag(:skill1, Search Skills for:) %
  %= text_field_tag(:skill1) %
  %= text_field_tag(:skill2) %
  %= submit_tag(Search) %
 % end %
 
 And are read in the controller by:
 
 def search
@people = Person.all
@skill_search1 = String.new
@skill_search1=:skill1.to_s
@skill_search2 = String.new
@skill_search2=:skill2.to_s
 
if @skill_search2.empty?
  @found_people = Person.where(skill_set LIKE ?,
 params[@skill_search1])
else
  @found_people = Person.where(skill_set LIKE ? and skill_set
 LIKE ?, params[@skill_search1],params[@skill_search2])
end
  end
 
 I have also tried: if @skill_search2  == NUL, ==   ,== nil,
 =='' and = under the theory that if you type in everything then
 something might work (hey, it's worked in the past!).
 
 Looking at the output in the command window that is used for the
 rails server call to WEBRick it seems that the second conditional
 option is always called and the statement ends in and skill_set LIKE
 ''   (that is 2 apostrophes before the final quote and, while it's a
 little hard to judge, I don't think there is a space between the
 apostrophes).
 So the question is: what is being returned by the blank text box
 and how should it be checked?
 Thanks,
Barney
 
 --
 You received this message because you are subscribed to the Google Groups 
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to 
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit this group 
 athttp://groups.google.com/group/rubyonrails-talk?hl=en.
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to 
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/rubyonrails-talk?hl=en.
 

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



Re: [Rails] associations seemed saved in console, but aren't

2011-07-20 Thread Eric Hu
My first guess would be that it has to do with the definitions for the
following methods:

create_tree_node
tree_node.create_definition


What happens if, after the IRB code you pasted in, you call

c.save
Course.all


(if that doesn't work, does the following work?)

c.interaction_outline.save
c.interaction_outline.tree_node.save
Course.all

On Tue, Jul 19, 2011 at 10:17 AM, Matt Garland li...@ruby-forum.com wrote:

 I have a Course model:

 class Course  ActiveRecord::Base

  belongs_to  :interaction_outline, :class_name = Tree, :foreign_key
 = interaction_outline_id
  belongs_to  :token_outline, :class_name = Tree, :foreign_key =
 token_outline_id

  after_save :make_outlines

  def make_outlines
  self.create_interaction_outline :name=
 self.name+_interaction_outline
self.create_token_outline :name= self.name+_token_outline
  end

 end

 After it is saved, the course creates some default outlines/trees. These
 in turn create some defaults:

 class Tree  ActiveRecord::Base

  has_many :edit_lists, :dependent= :destroy
  has_many :definitions, :dependent= :destroy
  has_many :courses
  belongs_to :tree_node #the top node

  validates_presence_of :name
  validates_uniqueness_of :name

  after_save :make_top

  def make_top
self.create_tree_node
self.tree_node.create_definition :name=top, :content=
 application/application
  end

 end

 The app is basically an outline editor that swaps in xml values for
 outline items.

 When I create a course in the console, all the defaults are created and
 associations set:

  c=Course.create :name=foo
 = #Course id: 5, name: foo, interaction_outline_id: 14,
 token_outline_id: 15, created_at: 2011-07-19 17:11:18, updated_at:
 2011-07-19 17:11:18
  c
 = #Course id: 5, name: foo, interaction_outline_id: 14,
 token_outline_id: 15, created_at: 2011-07-19 17:11:18, updated_at:
 2011-07-19 17:11:18
  c.interaction_outline
 = #Tree id: 14, name: foo_interaction_outline, tree_node_id: 14,
 created_at: 2011-07-19 17:11:18, updated_at: 2011-07-19 17:11:18
  c.interaction_outline.tree_node
 = #TreeNode id: 14, tree_id: nil, definition_id: 10, ancestry: nil,
 position: nil, created_at: 2011-07-19 17:11:18, updated_at:
 2011-07-19 17:11:18
  c.interaction_outline.tree_node.definition
 = #Definition id: 10, name: top, content:
 application/application, tree_id: 14, created_at: 2011-07-19
 17:11:18, updated_at: 2011-07-19 17:11:18

 HOWEVER, they are not actually saved:

  Course.all
 = [#Course id: 5, name: foo, interaction_outline_id: nil,
 token_outline_id: nil, created_at: 2011-07-19 17:11:18, updated_at:
 2011-07-19 17:11:18]
 What?

 This is the value returned by my controllers, too, with no foreign keys
 and thus no includes possible. Why?

 I have confirmed that all my composed objects are valid.

 Thanks!

 Matt

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

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



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



Re: [Rails] Re: Printing nested data to screen

2011-07-20 Thread Eric Hu
The original code didn't work because Barney was generating an ActiveRecord
Relation.  The .find almost worked, except he wanted to embed Ruby code in a
SQL statement.  This should do it:

PeopleSkill.where(people_id = #{@person.id}).find


In the future, I think something like Andrew's suggestion would be a lot
more readable and maintainable--I.E. using ActiveRecord to convert your
database information into objects, and looking for your information among
the objects instead of at the database level.


On Tue, Jul 19, 2011 at 5:17 PM, Andrew Skegg andrewsk...@me.com wrote:

 Barney bsperlin@... writes:

 
  Thanks Andrew, but I couldn't make the 'find' work on the
  'PeopleSkill.where...' line.  When I used 'find' on the @people_skill
  line it came very close (since in the controller, listed above,
  people_skill was already choosing the field 'skill'), so when I used:
   %= @people_skill.find(@person.id)
  and skipped the next line listed above, the SQLException was
  SQLite3::SQLException: near .: syntax error: SELECT  skill FROM
  people_skills WHERE people_skills.id = 23 AND (:people_id =
  @person.id) LIMIT 1
  which is VERY close to what I want, except that I want
  people_skills.people_id=23, not people_skill.id=23.  I know
  that 'find' always looks for the 'id' so I've got to get a different
  variation.
  What changes should I make?
   Thanks again,
  Barney

 What if we flip the logic?

 Assuming your models look something like:

 Person  ActiveRecord::Base
  has_and_belongs_to_many :skills
 end

 Skill  ActiveRecord::Base
  has_and_belongs_to_many :people
 end

 With the appropriate PeopleSkills join table in the database.

 Then:

 @person = Person.find(params[:id])
 @people_skill = @person.skills

 Or more easily:

 def show
@person = Person.find(params[:id])
 end

 and the view becomes:

 p
  bSkills/b
  %= @people.skills 
 /p

 or similar.





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



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



[Rails] QA Analyst - IN

2011-06-13 Thread Eric Hoffman
Dear Associate,

This is Eric Hoffman from Panzer Solutions LLC, Let me know if you suitable
consultant for below position. If so, send me your updated resume and
contact details.

*Position: QA Analyst
Location : Indianapolis, IN
Duration: 12 months*

*Rate: $35/hr*

Candidates HAVE to have several years of Rational Functional Tester exp as
well as Rational Quality Manager and ClearQuest.

Location : Indianapolis, IN
Length-12 Months

Responsible for assisting in the design/development of product
testing/quality processes and assists in developing testing architecture
equal to that of commercial quality software.
Assists in coordinating automation of test cases. Monitors current reference
architecture and monitors/collects testing/product quality data. Monitors
functional features, performance and service requirements/components.
Conducts testing to assure developed product conforms to requirements and
design. Assists in reviewing an application for testing needs and
requirements/design quality. Consults to projects and application support
groups regarding quality and testing and may participate in the transition
of software and systems into production. Prepares and executes test assets
and executes linkage from test plan to test scenarios and cases. Performs
other duties as assigned.

BA/BS in Computer Science or Information Systems or equivalent combination
of education and experience required. 1-3 years of testing/product quality
experience is preferred. SKILLS: Requires a basic understanding of
testing/product quality processes, tools and methods and an understanding or
organizational impacts and trade-offs of quality processes
- 5+ years of uautomated testing mission critical projects - Project Based
Testing!
 - Expertise with Rational Functional Tester (RFT)
 - Expertise with ClearQuest
 - Expertise with Rational Quality Manager(RQM)
 - Self directed and proactive
 - WP and/or Healthcare experience strongly prefered
 - QA Certification Preferred

Best Regards,
Eric Hoffman | Technical Recruiter
Voice: 203-971-8471
Email Id: e...@panzersoluitons.com

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



[Rails] Re: MySql2 adapter hangs in Rails3 on Windows XP

2011-06-10 Thread Eric Norberg
Installing 0.2.6 fixes it.  Thanks for information.

On Jun 9, 9:38 am, Dhruva Sagar dhruva.sa...@gmail.com wrote:
 On Thursday 09 June 2011 03:32 AM, Eric Norberg wrote:

  Previously we've used Rails2.xx with no problems and we're trying to
  upgrade to ruby 1.9.2p180 and Rails 3.0.7 with pik to keep ruby
  versions separate.

  After some initial difficulties withMySql2gem installation,
  followinga href=http://rorguide.blogspot.com/2011/03/installing-
 mysql2-gem-on-ruby-192-and.htmlthese tips/a  gotmysql2v0.2.7
  installed.

 Based on my recent experience, I had found v0.2.6 to work well, not sure
 if 0.2.7 is stable enough yet.

 --
 Thanks  Regards,
 Dhruva Sagar

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



[Rails] MySql2 adapter hangs in Rails3 on Windows XP

2011-06-09 Thread Eric Norberg
Previously we've used Rails2.xx with no problems and we're trying to
upgrade to ruby 1.9.2p180 and Rails 3.0.7 with pik to keep ruby
versions separate.

After some initial difficulties with MySql2 gem installation,
following a href=http://rorguide.blogspot.com/2011/03/installing-
mysql2-gem-on-ruby-192-and.htmlthese tips/a got mysql2 v0.2.7
installed.

My problem is that mysql2 hangs whenever I invoke it.  For instance,
rake db:create never finishes.

Similarly, rake db:migrate and rails console also hang.

In all cases, if I kill the hung process, there is a stack trace that
shows basically the same hung location:
(in C:/Projects/Rails3/xxx)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate   ---this never finishes.
^C
C:..some..path../mysql2_adapter.rb:312:in `query'
C:..some..path../mysql2_adapter.rb:312:in `execute'
C:..some..path../mysql2_adapter.rb:629:in `configure_connection'
snip
C:/Ruby192/lib/ruby/1.9.1/rake.rb:1992:in `run'
C:/Ruby192/bin/rake:31:in `main'

I've checked the Gemfile and run bundle install.

Here is a snippet from the database.yml
development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: xxx_schema_name_xxx
  pool: 5
  username: xxuser
  password: xxpwd
  host: xxx_dev.devhost.com
  port: 3306

I have reconfigured this for a db local on my PC and for a remotes db-
server.  Both of those databases respond normally to commandline mysql
monitor and to MySql Workbench.

The tests with sqlite3 databases work fine.

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



[Rails] Simple check_box

2011-05-19 Thread Eric M.
Hello,

I'm trying create a simple check_box that if checked include a
hidden_field, but I haven't success.

Something like this:
p class=field/p
%=  check_box_tag(:patrono, value = 1, checked = false, options =
{}) %
%= f.label Patrono %
% if :patrono.checked == true %
  %= f.hidden_field tipo_componente_ids][, { :id =
tipo_componente_ids, :value = @patrono.id } %
% end %
p/

Thanks for help!

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

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



[Rails] Re: [Form Helpers] Collection_select multiple and accepts_nested_attributes_for

2011-05-19 Thread Eric M.
Try this:

%= collection_select(:taggings, :tag_ids, Tag.find(:all), :id, :name, 
{}, {:multiple = true}) %

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

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



[Rails] Ruby on Rails Engineer - RoR - Software Engineer

2011-04-19 Thread Eric D.
Ruby on Rails Engineer - RoR - Software Engineer

We are looking for smart, motivated and mobile-savvy software engineers
to help strengthen, scale and evolve our proprietary messaging platform

Desirable Skills

* Ruby on Rails, Rails, Back-end development, PHP, Perl, Ruby, Java,
HTML, AJAX, UNIX/Linux,
MySql and erlang would be a plus!
* Knowledge of telephony protocols (SIP, RTP RTMP etc.) A plus
* Must be team-oriented, possess a positive attitude and work well with
others.
* Must be flexible and able to work accurately in a fast-paced
environment.
* Ability to work independently and deliver on schedule with little
supervision.
* Ability to quickly understand and articulate interactions in a complex
technical environment.
* Able to plan and execute own tasks in timely manner.
* Passionate about software development, willing to learn new
technology, self-motivated with high technical competency

Our office is located in sunny Venice Beach, California, a block from
the sand and surf (yep, we dress pretty casual around here). We offer
competitive compensation, provide full medical/dental/vision coverage,
and even help pay for your cellphone bill. We're an all-mac shop, so
expect a MacBook Pro on your first day.

Send Resume to Eric @ eric.dedomi...@mogreet.com

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

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



[Rails] Rails 2.3.7 and content_for problem

2011-03-03 Thread eric
I want to offer control over my app's navigation using multiple
yields, which worked fine on my home rails 3 installation, but at
work, I'm stuck with an app that uses 2.7, and the same approach isn't
working.

Basically, I have 3 yields: % yield :navigation% % yield :sidebar
% and regular ol' yield.

The regular one works fine, of course. However, the other two result
in certain tags being escaped: ul, li, nav, etc. The result is
that the tags appear as text in the display, and aren't interpreted by
the browser. I've tried the few suggestions I've found on the internet
(prefix the content_for with raw, etc), however, nothing has changed
the outcome. I should say that link_to in the content_for block is
properly handled and is not escaped, which is pretty interesting to
me.

I've reproduced the problem to a newly generated app with 1 scaffold
based class, with only minor alterations (adding the application.erb
and modifications to the index.html.erb file. Note that the navigation
content_for shows the list markup as text, but obeys the output of
link_to as markup.

application.erb:
!DOCTYPE html
html

  body
 section id=page
header
  nav%= raw yield :navigation %/nav
/header

   %= yield %

 /section
  /body
/html


index.html.erb:
% content_for :navigation do %
  ulli%= link_to 'New page', new_page_path %/li/ul
% end %

h1Listing pages/h1

table
  tr
thTitle/th
thBody/th
  /tr

% @pages.each do |page| %
  tr
td%=h page.title %/td
td%=h page.body %/td
td%= link_to 'Show', page %/td
td%= link_to 'Edit', edit_page_path(page) %/td
td%= link_to 'Destroy', page, :confirm = 'Are you
sure?', :method = :delete %/td
  /tr
% end %
/table

br /

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



[Rails] Re: Create super-simple adding application

2010-10-26 Thread Eric R.
Frederick Cheung wrote in post #957392:
 On Oct 26, 10:48pm, debalmoto debalm...@gmail.com wrote:
 p
 %= text_field_tag(:number_one, value = 0) %
 %= text_field_tag(:number_two, value = 0) %
 /p
 p
 %= @sum %
 /p

 That's all of it.

 Time for HTML lesson 1: if you want inputs to get sent to the server,
 they need to be enclosed in a form (modulo javascript trickery).

 Fred

Exactly.

So you may want to change the view code to look like this:

  %= form_tag('/') do -%
p
  %= text_field_tag(:number_one, value = 0)  %
  %= text_field_tag(:number_two, value = 0)  %
  %= submit_tag 'Calculate' %
/p
  % end %
p
  %= @sum %
/p

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

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



[Rails] Re: good hosting for Rails3 ?

2010-09-14 Thread Eric R.
The cheapest rails-friendly host I've come across is Site5. It's like 6 
bucks a month if I remember correctly, and you get unlimited storage and 
bandwidth. I don't think they've updated Rails to 3.0, but according to 
their blog that should be coming soon.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Rails is slow to load

2010-08-04 Thread Eric Yen
Hi,

I was just wondering if this was normal or not.

I was running ruby 1.8.7 with rails 3 - rc. (Currently trying 1.9.2-
rc2 but the same problem)
It takes rails a while to load. (a while as in 10-15 seconds)
It will take a while before I can use the console , or before running
a test or starting up the server.

This doesn't seem normal to me when I watch some screencasts.
If this is not normal behaviour, how can I figure out the source of
the problem?

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



[Rails] Re: Rails is slow to load

2010-08-04 Thread Eric Yen
That did cross my mind, but I was just wondering though.
Mostly because it didn't look as though the transition from running
the command to the actual test running wasn't edited.

But oh well.

On Aug 4, 2:54 pm, Fernando Perez li...@ruby-forum.com wrote:
  This doesn't seem normal to me when I watch some screencasts.
  If this is not normal behaviour, how can I figure out the source of
  the problem?

 Maybe they edited their videos to prevent wasting time watching rails
 load?
 --
 Posted viahttp://www.ruby-forum.com/.

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



[Rails] Re: [ANN] NullDB 0.0.1

2010-08-03 Thread Eric Schmitt
Marnen Laibow-Koser wrote:
 Avdi Grimm wrote:
 == What
 
 NullDB is a Rails database connection adapter that interprets common
 database operations as no-ops.  It is the Null Object pattern as
 applied to database adapters.
 [...]
 == Why
 
 NullDB is intended to assist in writing fast database-independant unit
 tests for ActiveRecord classes.  For why you would want to test your
 models without the database, see:
 http://www.dcmanges.com/blog/rails-unit-record-test-without-the-database.
 
 I'm not at all convinced that this is a good way of testing (and in my 
 experience, ThoughtWorks' software has lots of problems, which could say 
 something about their testing practices).  However, assuming for the 
 moment that it is good...
 [...]
 * It is *not* an in-memory database.  Finds will not work.  Neither
   will #reload, currently.
 
 So how is this of any use at all?  Normally, when I use tests with 
 database operations, I do so to confirm that I'm writing to the database 
 what I think I am.  (Sure, I could use RSpec's mocks to test that -- and 
 then I wouldn't need NullDB in the first place.)  By removing the 
 capability to save records, it seems to me that you've removed any 
 utility that this might have had.  Am I missing something?  How do *you* 
 find this puppy useful?
 
 Best,
 -- 
 Marnen Laibow-Koser
 http://www.marnen.org
 mar...@marnen.org
 
 Sent from my iPhone

Marnen,

I'm fairly new to unit testing and TDD, but I think I understand the 
concept of what they're talking about here. The point is that if you are 
writing to the database during unit tests, you're actually testing the 
database adapter and abstraction layer, in this case: ActiveRecord, and 
not the logic that you have written. ActiveRecord, has been tested 
extensively, it would be redundant to test it again. By removing the 
database from the testing, you can focus on testing your business 
logic... and you have the side benefit of it being quicker, which is 
essential for TDD to be a practical way to develop software. I think 
what you're describing is considered to be functional testing or 
integration test, not unit testing. Functional and integration testing 
is equally important, it just occurs at a different level.

This is one of the *rare* times when I think Ruby got it wrong when 
compared with other languages, most other more mature languages Java, 
C++, etc.. provide tools to avoid hitting the database during unit 
testing for just this reason. I think Rails, and Ruby in general is 
heading in this direction too. The next generation of ORM databases like 
DataMapper have this sort of thing built in. Hope this helps!

Cheers,
Eric

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

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



[Rails] Re: [ANN] NullDB 0.0.1

2010-08-03 Thread Eric Schmitt
 I'm fairly new to unit testing and TDD, but I think I understand the 
 concept of what they're talking about here. The point is that if you are 
 writing to the database during unit tests, you're actually testing the 
 database adapter and abstraction layer, in this case: ActiveRecord, and 
 not the logic that you have written. ActiveRecord, has been tested 
 extensively, it would be redundant to test it again. By removing the 
 database from the testing, you can focus on testing your business 
 logic... and you have the side benefit of it being quicker, which is 
 essential for TDD to be a practical way to develop software. I think 
 what you're describing is considered to be functional testing or 
 integration test, not unit testing. Functional and integration testing 
 is equally important, it just occurs at a different level.
 
 This is one of the *rare* times when I think Ruby got it wrong when 
 compared with other languages, most other more mature languages Java, 
 C++, etc.. provide tools to avoid hitting the database during unit 
 testing for just this reason. I think Rails, and Ruby in general is 
 heading in this direction too. The next generation of ORM databases like 
 DataMapper have this sort of thing built in. Hope this helps!
 
 Cheers,
 Eric

Oh, and I almost forgot to mention that Factory_Girl does this as well.
Using Factory.build() you only write to memory and not the database.
Factory_Girl can also allow writing to the database for functional and
integration testing, so you get the best of both worlds. It's one of the
pieces in my testing suite.

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

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



[Rails] Re: [ANN] NullDB 0.0.1

2010-08-03 Thread Eric Schmitt
Marnen,

You make some interesting points... I think I still have a ton to learn 
about unit testing and TDD best practices. I'm still just getting 
started. Thanks for the info!

Warmest Regards,
Eric
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: [ANN] NullDB 0.0.1

2010-08-02 Thread Eric Schmitt
Avdi Grimm wrote:
 Ed Howland wrote:
 Avdi,
 
 This sounds like a cool idea. One question. Would the usage pattern
 then be to use a mock/stub for the find methods and let the other save
 methods fall though to the NullDB connector?
 
 Yes, that's accurate.  Check the documentation for the latest revision, 
 too; there are some new RSpec helpers.
 
 --
 Avdi

Do you have any advice on how to setup NullDB in a JRuby environment? 
I'm using JRuby 1.5.1, Test::Unit, Shoulda, and will be using 
Factory_Girl for functional  and integration tests. I'm fairly new to 
unit testing so as much step by step as you can give would be great!

Cheers,
Eric
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: how to update a single table cell using ajax

2010-07-29 Thread Eric Yen
You can alwaus just do the following:

td id=descPlaceholder

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



[Rails] Migration: updating a column

2010-07-29 Thread Eric Yen
Hi,

Is there a way to update a column?

Here's what I mean:
I have a column name item in table products of type integer
Now I want to update the  column to have the option :null = false

So far, the only way I have found is to remove it and re-add it, but
obviously that is quite dumb.

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



[Rails] Re: Migration: updating a column

2010-07-29 Thread Eric Yen
Thanks.

I was under the impression that change_column was only for renaming.


On Jul 29, 9:19 am, Ar Chron li...@ruby-forum.com wrote:
 Have you tried change_column in a migration?

 http://api.rubyonrails.org/classes/ActiveRecord/Migration.html
 --
 Posted viahttp://www.ruby-forum.com/.

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



[Rails] Re: Ruby on Rails 3 RC and files in lib directory

2010-07-27 Thread Eric Yen
Hi,

Ading
 config.autoload_paths += %W(#{config.root}/lib)

to my application file solved it :)
Thank you so much

On Jul 27, 5:59 am, stephenjamesmurdoch
stephenjamesmurd...@gmail.com wrote:
 Hi Nicolas, i think I've fixed the problem

 add the following to your application.rb file:

     # Custom directories with classes and modules you want to be
 autoloadable.
     config.autoload_paths += %W(#{config.root}/lib)

 This code is generated when you create a brand new rails3rc app but
 not when you create a rails3b4 one...

 Also, in your rakefile, change:

     Rails::Application.load_tasks
 to
     YourAppName::Application.load_tasks

 I could be wrong but I think it's fixed the problem for me

 Cheers
 Steve
 On Jul 27, 9:12 am, Nicolas Blanco li...@ruby-forum.com wrote:



  Steve Murdoch wrote:
   sam problem here :(

   anyone know?

   I get:

     uninitialized constant ApplicationController::Authentication

   Obviously I could just move the methods from my lib/authentication.rb
   file into application_controller.rb but I'd prefer to see if there's
   another way first..

  Of course it's still possible to require manually files in lib but
  wanna know if that's a feature, not a bug :).
  --
  Posted viahttp://www.ruby-forum.com/.

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



[Rails] Test - Skip Setup

2010-07-27 Thread Eric Yen
Hi,

I want to write a functional test using the default test unit  that is
included with rails 3.
Is there a way to skip a setup call?

So I'm trying to test the users controller.
But to access those actions, I need to be logged in. So I put a login
algorithm in my setup.
But I do not need to be logged in to create a new user. This is why I
want to skip the setup call.

Eric

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



[Rails] Re: How to update user model attributes and bypass a presence_of validation?

2010-07-20 Thread Eric Hao
why not just use update_attribute ?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Rails 3 - AJAX Response

2010-06-22 Thread Eric Yen
Hi,

I need help with some AJAX in rails 3.

So basically, I have a select option in my index page for my User
model. This select option is a form that modifies the user's type. The
 :remote = true  works and the type is changed when hit the submit
button. But, nothing happens in the browser. The user is updated.

I'm actually not sure where to put either my JS / RJS file ( I've
tried both, but neither do anything.  )

So here's my code:

The form:

   %= form_for(@user, :remote = true) do |f|  %
%= f.select(type_id , Type.all.collect{ |t|
[t.name,t.id] } ) % #TYPE is another model. User belongs_to Type
%= f.submit Save  %
% end  %



The model:

class UsersController  ApplicationController
  skip_before_filter :authorize, :only = [:new, :create]
  # GET /users
  # GET /users.xml
  def index
@users = User.all

respond_to do |format|
  format.html # index.html.erb
  format.xml  { render :xml = @users }
end
  end

  # GET /users/1
  # GET /users/1.xml
  def show
@user = User.find(params[:id])

respond_to do |format|
  format.html # show.html.erb
  format.xml  { render :xml = @user }
end
  end

  # GET /users/new
  # GET /users/new.xml
  def new
@user = User.new

respond_to do |format|
  format.html # new.html.erb
  format.xml  { render :xml = @user }
end
  end

  # GET /users/1/edit
  def edit
@user = User.find(params[:id])
if params[:change_type]
change_type
end
  end

  # POST /users
  # POST /users.xml
  def create
@user = User.new(params[:user])

respond_to do |format|
  if @user.save
format.html { redirect_to(@user, :notice = 'User was
successfully created.') }
format.xml  { render :xml = @user, :status
= :created, :location = @user }
  else
format.html { render :action = new }
format.xml  { render :xml = @user.errors, :status
= :unprocessable_entity }
  end
end
  end

  # PUT /users/1
  # PUT /users/1.xml
  def update

@user = User.find(params[:id])

unless params[:user][:type_id]

@user = User.find(params[:id])

respond_to do |format|
  if @user.update_attributes(params[:user])
format.html { redirect_to(@user, :notice = 'User was
successfully updated.') }
format.js
format.xml  { head :ok }
  else
format.html { render :action = edit }
format.js
format.xml  { render :xml = @user.errors, :status
= :unprocessable_entity }
  end
end
else
  respond_to do |format|
if @user.update_attribute(type,
Type.find_by_id( params[:user][:type_id] ) )
  format.js{ head:ok}
else
  format.js {head:ok}
end
  end

end

  end


  def change_type
unless params[:change_type_value]
  if   @user.category == 5
  @user.category = 0
  else
@user.category = 5
  end


  respond_to do |format|
if @user.save
  format.html { redirect_to( users_path, :notice =
Sucessfully changed  + @user.name.titleize + 's category ) }
  format.js
else
  format.html { redirect_to( users_path, :notice = Failed to
change  + @user.name.titleize + 's category ) }
end
  end
end
  end

  # DELETE /users/1
  # DELETE /users/1.xml
  def destroy
@user = User.find(params[:id])
@user.destroy

respond_to do |format|
  format.html { redirect_to(users_url) }
  format.xml  { head :ok }
end
  end


end



The Response:

Started POST /users/1 for 127.0.0.1 at Tue Jun 22 23:31:07 -0400
2010
  Processing by UsersController#update as JS
  Parameters: {commit=Save, authenticity_token=OT1oYw/
cSiLrbT1w9PNu8A9u6v5eZy/bFxjbhEo3lbY=, id=1,
user={type_id=1}}
  User Load (0.9ms)  SELECT users.* FROM users WHERE (users.id
= 1) LIMIT 1
  CACHE (0.0ms)  SELECT users.* FROM users WHERE (users.id =
1) LIMIT 1
  Type Load (0.8ms)  SELECT types.* FROM types WHERE (types.id
= 1) LIMIT 1
Completed 200 OK in 347ms


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



  1   2   3   4   >