rubyonrailsin

A Ruby and Rails talk

Monday, March 15, 2010

Re: [Radiant-Dev] Wordpress Migrator

by rubyonrailsin 0 comments
Banane,

I'm not sure if your following the work we are doing on Radiant Themes http://github.com/sbmsuite/radiant-site_theme-extension

But we've agreed we should first develop a "theme" standard for radiant. Once we have the standard, I was going to start work on developing Wordpress migrator. I wasn't aware of Jim's work on this already. I'd be happy to work on this with you. Although I would really like to postpone working on migrating wordpress thems until we can make a little more progress with radiant-site_theme extension.

What do you think?

On Mon, Mar 15, 2010 at 4:52 PM, banane <banane@gmail.com> wrote:
OK I've spent the morning remembering how Radiant works after a monht
doing iPhone stuff, ha. I'm ready to get dirty working on ....
Wordpress Migrator (thanks to Jim for getting it started). Any
requests as I dive into this?

http://github.com/saturnflyer/radiant-wordpress_migrator-extension

I'm thinking:

First priority is to get this to work in one rake task, sequentially.
Most of this code base is moving the data over.
I'm not sure how to tackle migrating the CSS/front end in, as well as
the sidebar.
Widgets may be more of a "reporting what widges you are using" than
actually mapping them.


Anna

--
Radiant CMS Dev Mailing List
Post:        radiantcms-dev@googlegroups.com
Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
Group Site:  http://groups.google.com/group/radiantcms-dev/

--
Radiant CMS Dev Mailing List
Post: radiantcms-dev@googlegroups.com
Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
Group Site: http://groups.google.com/group/radiantcms-dev/
Read More…

[Radiant-Dev] Wordpress Migrator

by rubyonrailsin 0 comments
OK I've spent the morning remembering how Radiant works after a monht
doing iPhone stuff, ha. I'm ready to get dirty working on ....
Wordpress Migrator (thanks to Jim for getting it started). Any
requests as I dive into this?

http://github.com/saturnflyer/radiant-wordpress_migrator-extension

I'm thinking:

First priority is to get this to work in one rake task, sequentially.
Most of this code base is moving the data over.
I'm not sure how to tackle migrating the CSS/front end in, as well as
the sidebar.
Widgets may be more of a "reporting what widges you are using" than
actually mapping them.


Anna

--
Radiant CMS Dev Mailing List
Post: radiantcms-dev@googlegroups.com
Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
Group Site: http://groups.google.com/group/radiantcms-dev/

Read More…

Re: [Rails] Re: Figuring out the relationships between models.

by rubyonrailsin 0 comments
On 15 March 2010 16:48, Mr Horse <lists@ruby-forum.com> wrote:
> Thanks for the advice Aldric. This approach makes sense, but I get a
> little confused with the relationship between predictions and races.
>
> A prediction has_one race, but does this mean that a race must belong_to
> a prediction? While the first statement is correct (a prediction has_one
> race), a race has many predictions associated with it. Is it possible to
> state that a "race has_many predictions" as well as saying that a
> "prediction has_one race"?

No, as neither model would have the foreign key column, see below.

>
> I could say that a race has_many predictions and a prediction belongs_to
> a race, but it makes more sense to me to think of a prediction having a
> race as opposed to the other way around (a prediction belonging to a
> race).

This is the right way to do it even though prediction belongs_to race
sounds a bit odd. The model that 'belongs_to' is the one with the the
foreign key (prediction has a column race_id in this case). You will
find that belongs_to often does not seem quite the correct way of
stating the relationship, but if the has_many seems right (race
has_many predictions) and each of the predictions (in this case) is
associated with one (race in this case) then that is the way to do it.

Colin

>
> Eddie
> --
> 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+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

Re: [Radiant-Dev] replacing bluecloth with kramdown

by rubyonrailsin 0 comments
great news and thanks for the effort!

i think the kramdown branch in my fork is ready to merge. let me know
if there are any issues and i'll clear them up shortly.

http://github.com/johnmuhl/radiant/tree/kramdown

On Mon, Mar 15, 2010 at 2:43 PM, Jim Gay <jim@saturnflyer.com> wrote:
> On Feb 9, 2010, at 11:20 PM, M. Scott Ford wrote:
>
>>
>>>> To summarize, I now retract my assertion that having radiant depend on kramdown would be permitted. We could only do that if we make radiant licensed under the > terms of GPLv3. If I have overlooked something, or made a poor logical leap, then please point it out.
>>>
>>> radiant has been distributed with bluecloth 1.0.0 for years now which
>>> as i understand it is GPLv2.
>>> http://github.com/radiant/radiant/blob/master/vendor/extensions/markdown_filter/vendor/bluecloth/LICENSE
>>
>> I did not realize that. In order to be compliant with the BlueCloth 1.x license, any codebase that depends on it also has to be licensed under the GPL. This means that radiant's license is not compliant.
>>
>>> what about the bluecloth 2 option? it appears to BSD licensed.
>>> http://deveiate.org/projects/BlueCloth/browser/LICENSE
>>
>> The BSD license is very similar is spirit to the MIT license. The BSD license does not have a provision that restricts derivative works. It basically states that you can do whatever you want with the, but you can't sue the authors or use the fact that it was written by the authors as a means of promotion.
>
> As far as I understand, we are in the clear with this. I contacted the Free Software Foundation and got this reply back:
>
> Begin forwarded message:
>
>> Jim,
>>
>> I'm assuming that the "MIT license" you're talking about is the one we
>> call the Expat license, at <http://www.jclark.com/xml/copying.txt>.  If
>> that's the case, then yes, you can release a program that uses a
>> GPL-covered library under this license.  The Expat license is
>> GPL-compatible (http://www.fsf.org/licensing/licenses/#Expat), and our
>> FAQ explains that when you distribute a program that uses a GPLed
>> library, you may do so using a GPL-compatible license
>> (http://www.fsf.org/licensing/licenses/gpl-faq.html/#IfLibraryIsGPL).
>>
>> Please note that distribution of the combined program will still be
>> subject to the GPL's terms.  In other words, people won't be able to
>> distribute a proprietary version of the combined program, even though
>> the Expat license allows it, because the GPL would prohibit it.
>> However, people who do not combine your program with any GPL-covered
>> libraries may be able to use all of the permissions granted by the Expat
>> license.
>>
>> Best regards,
>>
>> --
>> Brett Smith
>> Licensing Compliance Engineer, Free Software Foundation
>
> --
> Radiant CMS Dev Mailing List
> Post:        radiantcms-dev@googlegroups.com
> Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
> Group Site:  http://groups.google.com/group/radiantcms-dev/

--
Radiant CMS Dev Mailing List
Post: radiantcms-dev@googlegroups.com
Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
Group Site: http://groups.google.com/group/radiantcms-dev/

Read More…

[Rails] JS not recognized in link_to_remote respond_to?

by rubyonrailsin 0 comments
In my view I have this test...

<%= link_to_remote('AJAX Alert', :url => '/sandbox/submit', :success
=> 'alert(request.responseText)') %>

In my controller, this works and alerts "AJAX Response"...

def submit
render :layout => false
end

But if I add the respond_to block, the format.js never gets
recognized...

def submit
respond_to do |format|
format.js {
render :layout => false
}
format.html {
# render normal layout
}
end
end

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

Read More…

Re: [Rails] Re: Dependency warning found on fresh rails 2.3.5 installati

by rubyonrailsin 0 comments
Yep. Thanks for that but I find it weird because on my older machine which runs rails 2.3.5 and ruby 1.8.7, it doesn't happen.

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

[Rails] JS not recognized in link_to_remote respond_to?

by rubyonrailsin 0 comments
In my view I have this test...

<%= link_to_remote('AJAX Alert', :url => '/sandbox/submit', :success
=> 'alert(request.responseText)') %>

In my controller, this works and outputs "AJAX Response"...

def submit
render :layout => false
end

But if I add the respond_to block, the format.js never gets
recognized...

def submit
respond_to do |format|
format.js {
render :layout => false
}
format.any(:html, :mobi, :touch) {
# render normal layout
}
end
end

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

Read More…

[Rails] Re: Problem with Getting Started with Rails

by rubyonrailsin 0 comments
Neil Bye wrote:
> I am working through the official Getting Started with Rails tutorial
> http://guides.rubyonrails.org/getting_started.html#generating%20-a-controller
>
> I am stuck on section 8.4 Generating a Controller. It suggests there
> that this definition:
> def index
> @post = Post.find(params[:post_id])
> @comments = @post.comments
> end
>
> S ould be used in com ents_controller.rb. Surely that would make
> http://localhost:3000/comments work, but it gives the error
> Couldn't find Post without an ID. That suggests a problem with the first
> line of the definition. However that is what it says I should use in the
> tutorial so I looked at post.rb and comment.rb and they are as directed.
> Also checked routes.rb but all seems to be correct. Incidentally the
> page http://localhost:3000/posts/1
> works fine and displays comments which I have to enter with the terminal
> as http://localhost:3000/comments/new gives the same error.

Take a closer look at this URL:
http://localhost:3000/comments

How would the comments_controller know which post to look up. The
resource identifier is not anywhere in the URL and it's not tacked on as
a query parameter.

The most likely design in this case would be to nest comments under
posts. The URL would look something like:

http://localhost:3000/posts/1/comments/new

And the new action would look something like:

def new
@post = Post.find(params[:post_id])
@comment = @post.comments.build
end

If course you're going to want to DRY up this code by moving:

@post = Post.find(params[:post_id])

Into a private method and adding a before_filter to load the post.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] Re: refresh a page using AJAX?

by rubyonrailsin 0 comments
Veena Jose wrote:
> I want to know how a part of the webpage (data obtained from
> database) can be refreshed at periodic intervals(say 5 sec).
> I have tried periodically_call_remote() method.But it is not working
> for me.
>
> <% periodically_call_remote(:url => { :action =>
> :show_readings_for_station },
> :frequency => 5, :update => "reading_list")%>
> <div id="reading_list">
> #my code here which obtains data from database
> </div>
>
> show_readings_for_station is a method in the controller.....

Just to be sure, you did put:

<%= javascript_include_tag :defaults %>

inside your <head></head> section right?
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] Re: Re: more than one table per model

by rubyonrailsin 0 comments
Frank Kim wrote:
> Okay here's why I want to do it.
> The first table contains just data.
> The second table will be a view whose data can change depending on
> other external factors. It could change daily.
> Yes this second table could be an association but I would have
> preferred it not to be.

I don't think ActiveRecord is going to be your friend here. AFAIK
ActiveRecord expects a model to represent a single database table.

For instance you can override the conventional mapping of a model to a
table using;

set_table_name "my_table_name"

However, I know of no way to set multiple table names to one model. You
can certainly use more than one model mapped to a single table (STI).
But, not the other way around (again AFAIK).

Beside this, much of the functionality of ActiveRecord would no longer
work. How would it know which tables are represented by the model, and
which attributes belongs to which table. It would not have the benefit
of a join in order to determine what goes where.

Just my 2 cents.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

Re: [Rails] Re: Most popular IDEs for Ruby on Rails development

by rubyonrailsin 0 comments
On 15 March 2010 19:53, Greg Donald <gdonald@gmail.com> wrote:
>> How is it harder to learn the IDE keyboard shortcuts that it is to
>> learn Emacs'?
>
> I didn't say it was harder, but you only get what it came
> pre-programmed with for the most part.  Some of them offer some added
> shortcut functionality but nothing anywhere close to the power of
> making your own key binding in Lisp.

You commented that your primary objection to IDEs was that they cause
you to take your fingers off the keyboard - I suggested that it's
possible to navigate through (Ruby) projects all day with little use
of the mouse, and also that some people aren't *that* concerned about
the hassle involved in moving their hand to a different input
mechanism.

<snip swathes of awesome features>

Sure, there's loads of pro's to your favoured development environment
(integrated or not) that cause *you* to experience great productivity;
given the OP's query, that's all valuable input for him (if he ever
comes back to this thread!) but it's a little rude to dismiss people
as 2nd class or worse because of the tools they use, or the fact that
they care less about their RAM use, or shutting down their computer at
night; essentially because they have different priorities to you.

> If its your job to write code then just write the code.

That's certainly what a good corporate coding drone should do. I'm not
one of those; I certainly program, but I'm not a "programmer"
exclusively.

>> I've sat next to people at both extremes; of
>> typing lots of noise, and typing amazing code with very few
>> keypresses,
>
> Yeah, that's the .net people, plugging components together requires
> very little typing, and very little programming skills for that
> matter.

Can't comment, I'm afraid, I've no particular exposure with .Net (and
it was not my intention to make a comment about different peoples'
productivity a reference to which language is "better")

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

Read More…

Re: [Rails] Re: Most popular IDEs for Ruby on Rails development

by rubyonrailsin 0 comments
On Mon, Mar 15, 2010 at 2:09 PM, Michael Pavling <pavling@gmail.com> wrote:
>> And people who shy away from that power aren't really programmers IMO.
>
> Good job it's worth a whole 2pence :-/

I'll take it. Paypal work?

> How is it harder to learn the IDE keyboard shortcuts that it is to
> learn Emacs'?

I didn't say it was harder, but you only get what it came
pre-programmed with for the most part. Some of them offer some added
shortcut functionality but nothing anywhere close to the power of
making your own key binding in Lisp.

Another thing is I can start Emacs once and run it until my next
reboot, weeks or months from now. I have to restart Eclipse every few
hours or so. I can start Emacs in a screen and continue my work from
home later in the evening. I can background Emacs and type shell
commands. It's so much more.

IDEs usually have a large memory footprint. Eclipse uses over half a
GB of ram on my system. Emacs uses 13MBs of ram, but that's only
because I have a ton of stuff loaded like ERC, ECB, and Gnus.

> Typically, it would be worth adding "YMMV" to your
> previous statement, because other people may find there isn't a direct
> correlation between the ratio of their keyboard:mouse contact and
> their productivity -

If its your job to write code then just write the code. Are you a
programmer or not?

> I've sat next to people at both extremes; of
> typing lots of noise, and typing amazing code with very few
> keypresses,

Yeah, that's the .net people, plugging components together requires
very little typing, and very little programming skills for that
matter.

> regardless of their development environment.
>
> (of course, YMMV ;-)

Yup.


--
Greg Donald
destiney.com | gregdonald.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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

Re: [Radiant-Dev] replacing bluecloth with kramdown

by rubyonrailsin 0 comments
On Feb 9, 2010, at 11:20 PM, M. Scott Ford wrote:

>
>>> To summarize, I now retract my assertion that having radiant depend on kramdown would be permitted. We could only do that if we make radiant licensed under the > terms of GPLv3. If I have overlooked something, or made a poor logical leap, then please point it out.
>>
>> radiant has been distributed with bluecloth 1.0.0 for years now which
>> as i understand it is GPLv2.
>> http://github.com/radiant/radiant/blob/master/vendor/extensions/markdown_filter/vendor/bluecloth/LICENSE
>
> I did not realize that. In order to be compliant with the BlueCloth 1.x license, any codebase that depends on it also has to be licensed under the GPL. This means that radiant's license is not compliant.
>
>> what about the bluecloth 2 option? it appears to BSD licensed.
>> http://deveiate.org/projects/BlueCloth/browser/LICENSE
>
> The BSD license is very similar is spirit to the MIT license. The BSD license does not have a provision that restricts derivative works. It basically states that you can do whatever you want with the, but you can't sue the authors or use the fact that it was written by the authors as a means of promotion.

As far as I understand, we are in the clear with this. I contacted the Free Software Foundation and got this reply back:

Begin forwarded message:

> Jim,
>
> I'm assuming that the "MIT license" you're talking about is the one we
> call the Expat license, at <http://www.jclark.com/xml/copying.txt>. If
> that's the case, then yes, you can release a program that uses a
> GPL-covered library under this license. The Expat license is
> GPL-compatible (http://www.fsf.org/licensing/licenses/#Expat), and our
> FAQ explains that when you distribute a program that uses a GPLed
> library, you may do so using a GPL-compatible license
> (http://www.fsf.org/licensing/licenses/gpl-faq.html/#IfLibraryIsGPL).
>
> Please note that distribution of the combined program will still be
> subject to the GPL's terms. In other words, people won't be able to
> distribute a proprietary version of the combined program, even though
> the Expat license allows it, because the GPL would prohibit it.
> However, people who do not combine your program with any GPL-covered
> libraries may be able to use all of the permissions granted by the Expat
> license.
>
> Best regards,
>
> --
> Brett Smith
> Licensing Compliance Engineer, Free Software Foundation

--
Radiant CMS Dev Mailing List
Post: radiantcms-dev@googlegroups.com
Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
Group Site: http://groups.google.com/group/radiantcms-dev/

Read More…

Re: [spree-user] hook proposals

by rubyonrailsin 0 comments
On Mon, Mar 15, 2010 at 2:25 PM, Stephanie Powell <steph@endpoint.com> wrote:
> Hi,
>
> Sean mentioned to run hook proposals through spree-user in case we wanted to
> recommend them.
>
> Here are ones that have come up in a few different client projects
>
> - hook around footer contents (client needs custom footer text added, but we
> still want core footer fxnality included)
> - hook around order form, but inside <form></form> (client needs an
> additional form field inside the checkout form)

We could also use the hook inside the order form.

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To post to this group, send email to spree-user@googlegroups.com.
To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Read More…

[spree-user] Re: Third party Payment Gateway on edge

by rubyonrailsin 0 comments
Ajay,

Just woke up, hopped on here, and saw your response, Ill go through it
and make of it what I can,

Thankyou very much, appreciate it!

Cameron

On Mar 16, 8:10 am, Ajay CB <ajay...@gmail.com> wrote:
> Hi,
>
> I am half way through the implementation. There are many rough edges
> that I am still working out.
>
> Before I outline the solution here are the problems with hosted
> gateways
> (Hopefully it will help when someone else wants to take a shot at it)
>
> It relies on heavily browser redirects - this may not seem to be a
> problem at first, but it is a PITA.
> Once the amount + other details are passed on to the Payment Gateway
> via a form post, the possible outcomes are as follows:
> a) Happy flow - the customer selects the payment instrument and makes
> the payment, Once done he is redirected back to the registered
> callback URL.
> Process the payment as success and life goes on. no problems.
> b) Unsuccessful flow - Customer makes a bad payment, eg. expired card
> and such, he is redirected back with failure as the status - Do not
> record the payment on the order - keep the checkout alive, report the
> error and ask the customer to retry
> c) Broken flow - (a) or (b) happens and the last redirect does not
> happen because of a system failure - say network issue/etc. Now, we do
> not know if the payment was successful or not. This is a stuck order
> and needs to be cleared on a regular basis.
> The problem gets worse if the payment succeeds and the customer makes
> another payment (as the cart/checkout is still alive) thinking it
> failed. Now we have 2 payments for the same order.
> One more ugly case is: the customer changes the cart. Here we lose
> track of what he actually ordered even if we manage to salvage the
> payment.
>
> Here is a brief of the approach that has worked for me - it handles
> only cases (a) and (b). I am still working out a solution for (c)
> It may not be the most suitable implementation per spree's way of
> thought but it works for me -
>
> Assumptions:
> There will be only one hosted payment gateway - atleast thats my
> requirement so I didn't make it generic. Once I get to a stable
> working version, I may refactor it.
>
> Steps:
> a) Create a new extension for the payment gateway with 2 models.
> RequestLog and ResponseLog.
> Request log will record all attempts to the payment gateway(with order
> details) and ResponseLog will log all responses good or bad from the
> gateway.
> This can also be useful for debugging.
> To handle the broken flow outlined above, we need to be able to
> recreate the order from the request log if the need arises.
> c) create a controller with a return method (with its route) and
> create a method that you can configure as your return url
> d) Create a model for your pamentgateway that extends Gateway.
> Override
>   def method_type
>     "hosted_gateway"
>   end
> This will give you access to a new partial which will be called from
> _payment.html.erb
>
> Under app/views/checkouts/payment, create a _hosted_gateway.html.erb
> that will be called for your hosted gateway
>
> Note: I conditionally removed everything from _payment.html if
> @payment_methods.length == 1 and @payment_methods.method_type
> =="hosted_gateway" and included only partial in that case (this is
> because of my assumption) - you can also add another step in the
> checkout instead of riding over payments, but I ran into issues with
> that and hence this approach
>
> My _hosted_gateway.html.erb looks like this:
>
> <form action="<%=payment_method.request_url %>" method="post">
>
>   <% payment_method.request_form_fields(@order).each do |tag| %>
>     <%= tag %>
>   <% end %>
>
>   <%= submit_tag %>
> </form>
>
> request_url and request_form_fields are implemented by the payment
> gateway. to help build the form that will post to the gateway.
> The gateway in my case was configured (via the request params) to
> callback the url configured in (c)
>
> my return method looks like this:
>
>   def process_return
>     ccavenue = PaymentMethod.find_by_type('Gateway::CCAvenue')
>     order, is_payment_success = ccavenue.process_response(params)
>
>     if is_payment_success
>       checkout = order.checkout
>       checkout.payments.clear
>       payment = order.checkout.payments.create
>       payment.amount = params[:Amount]
>       payment.payment_method = ccavenue
>       checkout.save
>       checkout.next!
>
>       if checkout.completed_at
>         session[:order_id] = nil
>         flash[:commerce_tracking] =
> I18n.t("notice_messages.track_me_in_GA")
>       end
>
>       redirect_to order_url(order, {:checkout_complete => true})
>     else
>       #todo: failure needs to be handled properly
>       redirect_to order_checkout_path(order)
>     end
>
> This has been long! hopefully it helps you. If anyone else has a
> better shot at this problem I would be glad to test/extend it :)
>
> -Ajay
>
> On Mar 15, 12:06 am, Cameron <czcar...@gmail.com> wrote:
>
> > Hi Ajay,
>
> > If you manage to accomplish this would appreciate a write-up of some
> > description - after talking to a couple of providers in NZ, they all
> > strongly "suggest" I use a redirect to a hosted page, curious as to
> > how you work it out,
>
> > Regards,
>
> > Cameron
>
> > On Mar 10, 11:34 am, BryanMTL <bryan...@gmail.com> wrote:
>
> > > Hi Ajay,
>
> > > I recently completed something for this. I'm just reviewing it with
> > > the client and I believe he has plans on open-sourcing it.
>
> > > On Mar 9, 3:01 pm, Ajay CB <ajay...@gmail.com> wrote:
>
> > > > I am looking at implementing a new Payment Gateway on spree edge.
>
> > > > Requirement is to do a client side redirect to the payment gateway
> > > > (where the payment is made) and on successful completion - i.e
> > > > redirect to the success url, the order gets confirmed (checkout
> > > > complete) on failure, make the customer retry the payment (basically
> > > > another url endpoint for failure).
>
> > > > On the admin side, pretty much everything is manual - it sucks but I
> > > > am stuck with this gateway. The workflow to settle a payment is
> > > > closest to cheques. i.e just finalizing the payment will suffice.
>
> > > > Is there any existing payment gateway that works on this model, that I
> > > > can look at for an example?
> > > > If not what is the best way of going about this on the edge, given the
> > > > payment gateway refactoring.
>
> > > > Any suggestions/pointers will be of great help.
>
> > > > Thanks!
> > > > -Ajay
>
>

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To post to this group, send email to spree-user@googlegroups.com.
To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Read More…

[spree-user] Re: Third party Payment Gateway on edge

by rubyonrailsin 0 comments
Hi,

I am half way through the implementation. There are many rough edges
that I am still working out.

Before I outline the solution here are the problems with hosted
gateways
(Hopefully it will help when someone else wants to take a shot at it)

It relies on heavily browser redirects - this may not seem to be a
problem at first, but it is a PITA.
Once the amount + other details are passed on to the Payment Gateway
via a form post, the possible outcomes are as follows:
a) Happy flow - the customer selects the payment instrument and makes
the payment, Once done he is redirected back to the registered
callback URL.
Process the payment as success and life goes on. no problems.
b) Unsuccessful flow - Customer makes a bad payment, eg. expired card
and such, he is redirected back with failure as the status - Do not
record the payment on the order - keep the checkout alive, report the
error and ask the customer to retry
c) Broken flow - (a) or (b) happens and the last redirect does not
happen because of a system failure - say network issue/etc. Now, we do
not know if the payment was successful or not. This is a stuck order
and needs to be cleared on a regular basis.
The problem gets worse if the payment succeeds and the customer makes
another payment (as the cart/checkout is still alive) thinking it
failed. Now we have 2 payments for the same order.
One more ugly case is: the customer changes the cart. Here we lose
track of what he actually ordered even if we manage to salvage the
payment.

Here is a brief of the approach that has worked for me - it handles
only cases (a) and (b). I am still working out a solution for (c)
It may not be the most suitable implementation per spree's way of
thought but it works for me -

Assumptions:
There will be only one hosted payment gateway - atleast thats my
requirement so I didn't make it generic. Once I get to a stable
working version, I may refactor it.

Steps:
a) Create a new extension for the payment gateway with 2 models.
RequestLog and ResponseLog.
Request log will record all attempts to the payment gateway(with order
details) and ResponseLog will log all responses good or bad from the
gateway.
This can also be useful for debugging.
To handle the broken flow outlined above, we need to be able to
recreate the order from the request log if the need arises.
c) create a controller with a return method (with its route) and
create a method that you can configure as your return url
d) Create a model for your pamentgateway that extends Gateway.
Override
def method_type
"hosted_gateway"
end
This will give you access to a new partial which will be called from
_payment.html.erb

Under app/views/checkouts/payment, create a _hosted_gateway.html.erb
that will be called for your hosted gateway

Note: I conditionally removed everything from _payment.html if
@payment_methods.length == 1 and @payment_methods.method_type
=="hosted_gateway" and included only partial in that case (this is
because of my assumption) - you can also add another step in the
checkout instead of riding over payments, but I ran into issues with
that and hence this approach

My _hosted_gateway.html.erb looks like this:

<form action="<%=payment_method.request_url %>" method="post">

<% payment_method.request_form_fields(@order).each do |tag| %>
<%= tag %>
<% end %>

<%= submit_tag %>
</form>

request_url and request_form_fields are implemented by the payment
gateway. to help build the form that will post to the gateway.
The gateway in my case was configured (via the request params) to
callback the url configured in (c)

my return method looks like this:

def process_return
ccavenue = PaymentMethod.find_by_type('Gateway::CCAvenue')
order, is_payment_success = ccavenue.process_response(params)

if is_payment_success
checkout = order.checkout
checkout.payments.clear
payment = order.checkout.payments.create
payment.amount = params[:Amount]
payment.payment_method = ccavenue
checkout.save
checkout.next!

if checkout.completed_at
session[:order_id] = nil
flash[:commerce_tracking] =
I18n.t("notice_messages.track_me_in_GA")
end

redirect_to order_url(order, {:checkout_complete => true})
else
#todo: failure needs to be handled properly
redirect_to order_checkout_path(order)
end


This has been long! hopefully it helps you. If anyone else has a
better shot at this problem I would be glad to test/extend it :)

-Ajay

On Mar 15, 12:06 am, Cameron <czcar...@gmail.com> wrote:
> Hi Ajay,
>
> If you manage to accomplish this would appreciate a write-up of some
> description - after talking to a couple of providers in NZ, they all
> strongly "suggest" I use a redirect to a hosted page, curious as to
> how you work it out,
>
> Regards,
>
> Cameron
>
> On Mar 10, 11:34 am, BryanMTL <bryan...@gmail.com> wrote:
>
> > Hi Ajay,
>
> > I recently completed something for this. I'm just reviewing it with
> > the client and I believe he has plans on open-sourcing it.
>
> > On Mar 9, 3:01 pm, Ajay CB <ajay...@gmail.com> wrote:
>
> > > I am looking at implementing a new Payment Gateway on spree edge.
>
> > > Requirement is to do a client side redirect to the payment gateway
> > > (where the payment is made) and on successful completion - i.e
> > > redirect to the success url, the order gets confirmed (checkout
> > > complete) on failure, make the customer retry the payment (basically
> > > another url endpoint for failure).
>
> > > On the admin side, pretty much everything is manual - it sucks but I
> > > am stuck with this gateway. The workflow to settle a payment is
> > > closest to cheques. i.e just finalizing the payment will suffice.
>
> > > Is there any existing payment gateway that works on this model, that I
> > > can look at for an example?
> > > If not what is the best way of going about this on the edge, given the
> > > payment gateway refactoring.
>
> > > Any suggestions/pointers will be of great help.
>
> > > Thanks!
> > > -Ajay

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To post to this group, send email to spree-user@googlegroups.com.
To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Read More…

Re: [Rails] Re: Most popular IDEs for Ruby on Rails development

by rubyonrailsin 0 comments
On 15 March 2010 17:40, Greg Donald <gdonald@gmail.com> wrote:
> On Mon, Mar 15, 2010 at 11:22 AM, Norm Scherer wrote:
>> Emacs can be made to do anything!
>
> And people who shy away from that power aren't really programmers IMO.

Good job it's worth a whole 2pence :-/

> IDEs make me touch my mouse way too much.  The longer I can keep my
> hands directly on the keyboard, the more productive I am.  It's not
> difficult to understand.

How is it harder to learn the IDE keyboard shortcuts that it is to
learn Emacs'? Typically, it would be worth adding "YMMV" to your
previous statement, because other people may find there isn't a direct
correlation between the ratio of their keyboard:mouse contact and
their productivity - I've sat next to people at both extremes; of
typing lots of noise, and typing amazing code with very few
keypresses, regardless of their development environment.

(of course, YMMV ;-)

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

Read More…

[Rails] Re: Upgrading rails, ruby and gems

by rubyonrailsin 0 comments
Yudi Soesanto wrote:
> Hi guys,
>
> Is there any good documentation to upgrade rails, ruby and supported
> gems? I
> use mac tiger.
> Also, what is the stable version of ruby?

Upgrade RubyGems with:
sudo gem update --system

Upgrade to the latest Rails with:
sudo gem install rails

Upgrade gems with:
sudo gem install <gem_name>

I'm currently running Ruby 1.8.7 (2008-08-11 patchlevel 72) on Mac OS X
10.6.2.

Here's a guide I used to use before Mac OS X 10.5+ made it irrelevant.
(at least for me):
http://hivelogic.com/articles/ruby-rails-mongrel-mysql-osx
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

Re: [Rails] Re: more than one table per model

by rubyonrailsin 0 comments
On 15 March 2010 18:14, Greg Donald <gdonald@gmail.com> wrote:
> On Mon, Mar 15, 2010 at 12:18 PM, Aldric Giacomoni <lists@ruby-forum.com> wrote:
>> What possible benefit could you derive from this
>
> A second table is required when you have constraints that you don't
> want interfering with your ability to save data to the first table.
> has_one is very useful for this scenario.

I can't tell what your angle is from this post - are you disagreeing
with Aldric, or the OP?

A has_one is the association the OP said he didn't want; and the idea
of a second table with no association is what Aldric seems to be
querying.

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

Read More…

[Rails] Re: Dependency warning found on fresh rails 2.3.5 installati

by rubyonrailsin 0 comments
ct9a wrote:
> hi guys,
>
> I just installed rails 2.3.5 and ruby 1.9 on a new ubuntu karmic
> koala machine.
>
> For some silly reason, when I run "script/server", I got the following
> warning..
>
> /usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/rails/
> gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is
> deprecated and will be removed on or after August 2010.
>
> This is a fresh installation. Why is this error surfacing?

I assume you installed the latest version of RubyGems. I'm also getting
this warning. As far as I can tell it's not causing any problems, and
the only way to fix it would be to fork Rails and fix it there.

So bottom line is, don't worry about it unless it's causing you
problems. I expect this will get fixed in the next release of Rails.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] Re: validates_presence_of :parent_id stopping save

by rubyonrailsin 0 comments
Hi Max,

Have you tried:

@question = Question.create(attributes)
@grading = @question.gradings.build(more_attrs)

Using create instead of new will save the Object to the DB first, and
hence:

@question[:id] will/should/may not be nil when building your gradings.

I'm six months in to Rails, don't use build, and haven't needed to use
any validation yet - am currently extending the generator for my
current and future Apps, so I have held fire on my first app until I
get this completed, but if your only issue is that the FK question_id
requires @question[:id] to exist, then unless I'm mistaken(which I
could be), using create over new should work.......

HTH

Paul

On Mar 13, 3:54 pm, Max Williams <li...@ruby-forum.com> wrote:
> Hi. I'm using rails 2.3.4 and have this association between two of my
> models.
>
> Question
>   has_many :gradings
>
> Grading
>   belongs_to :question
>
> Grading has this validation:
>   validates_presence_of :question_id
>
> And this validation test is stopping me from doingg this, which i would
> normally expect to work
>
> @question = Question.new(attributes)
> @grading = @question.gradings.build(more_attributes)
> @question.save #fails because grading has no question_id
>
> Now, i thought that this would work ok because (in my understanding) the
> question is saved and then it saves it's built associated objects.  How
> can i ensure this will work?  Do i need to drop the validation?  I'd
> rather not if possible.
>
> Grateful for any advice - max
> --
> 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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] Re: Undefined method when creating a has_many relationship

by rubyonrailsin 0 comments
Thanks, Fred - very helpful orientation. I assumed (mistakenly,
obviously) that form_for would see the foreign key in @rcost and
therefore know the @resource instance it should be associated with.

I searched around and found two recommendations that appear to address
this issue I am having:

<% form_for([@resource, @rcost]) do |f| %>
and
<% form_for([:resource, @rcost]) do |f| %>

Not sure how behavior will differ with each version, but I will try
them and report back on my results.

Mark


On Mar 15, 2:58 am, Frederick Cheung <frederick.che...@gmail.com>
wrote:
> On Mar 15, 5:42 am, MarkB <mark_ba...@hotmail.com> wrote:
>
> > My first attempt at working with a newhas_manyrelationship is
> > throwing an error in the view when I try to create a new 'rcost'
> > instance linked to a 'resource' (each resource can have multiple
> > costs):
>
> > "undefined method `rcosts_path' for #<ActionView::Base:0x715bc60>"
>
> > Here is the view (new.html.erb) code that appears to be causing the
> > error (I do not reference rcosts_path anywhere in the view):
>
> > <% form_for(@rcost) do |f| %>
>
> rcosts_path is being invoked by form_for, when it computes where the
> form should be posting too. Since you've got a nested resource you've
> got to tell form_for which Resource this @rcost belongs to.
>
> Fred

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

Read More…

[spree-user] hook proposals

by rubyonrailsin 0 comments
Hi,

Sean mentioned to run hook proposals through spree-user in case we
wanted to recommend them.

Here are ones that have come up in a few different client projects

- hook around footer contents (client needs custom footer text added,
but we still want core footer fxnality included)
- hook around order form, but inside <form></form> (client needs an
additional form field inside the checkout form)
- hook around some admin forms (i realize there are some of these
already, but for example, one on the general settings page inside the
<form></form> tag would be nice to incorporate additional settings)

In all of these projects, I've accomplished the desired functionality by
overriding the views (shared/footer, checkouts/edit,
admin/general_settings), and I realize that not everyone will need these
specific hooks, but I don't really want to have to maintain these files
every time there's a change to them. Perhaps the footer hook would be
the minimum to include?

If approved, I'd like to submit a patch when I have time :)

Thanks,

Steph

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To post to this group, send email to spree-user@googlegroups.com.
To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Read More…

[Rails] Re: RESTful route question

by rubyonrailsin 0 comments
On Mar 15, 7:59 am, daphonz <cdre...@gmail.com> wrote:
> Have you tried just making a hidden field for the patient id?

That's an interesting design thought, which I'll play with. But it
seems to me I should still be able to configure the route in a RESTful
way. Any idea how?

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

Read More…

Re: [Rails] Re: more than one table per model

by rubyonrailsin 0 comments
On Mon, Mar 15, 2010 at 12:18 PM, Aldric Giacomoni <lists@ruby-forum.com> wrote:
> What possible benefit could you derive from this

A second table is required when you have constraints that you don't
want interfering with your ability to save data to the first table.
has_one is very useful for this scenario.


--
Greg Donald
destiney.com | gregdonald.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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] Re: How to access multiple models in a single controller

by rubyonrailsin 0 comments
On Mar 15, 5:53 pm, richardsugg <richards...@gmail.com> wrote:
> So in my CompanyController, I have functions index, new, edit, create,
> show, etc... My understanding is that one of these gets called
> depending on the page.  If I'm creating a new company, then the new/
> create is called, etc.  How do I create a function that is called
> everytime, regardless of the context?
>

Sounds like you are looking for a before_filter

Fred

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

Read More…

[Rails] Re: How to access multiple models in a single controller

by rubyonrailsin 0 comments
So in my CompanyController, I have functions index, new, edit, create,
show, etc... My understanding is that one of these gets called
depending on the page. If I'm creating a new company, then the new/
create is called, etc. How do I create a function that is called
everytime, regardless of the context?


On Mar 10, 4:31 pm, Tim Shaffer <timster...@gmail.com> wrote:
> You should be able to access your Company model from any controller.
>
> On Mar 10, 2:33 pm,richardsugg<richards...@gmail.com> wrote:
>
> > I am creating a customer database.  The navigation menu will have
> > sections for supported customers, trial customers, unsupported
> > customers, etc.  The nav menu will appear on every page.
>
> > I need to get the list of customers (i.e., supported customers), but
> > since I'm not using the company controller, I don't have access to the
> > methods that return the Company model data.  How can I get the
> > Application controller to access the Company model?
>
> > Thanks,
> > Richard

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

Read More…

[Rails] Re: Re: more than one table per model

by rubyonrailsin 0 comments
Frank Kim wrote:
> Okay here's why I want to do it.
> The first table contains just data.
> The second table will be a view whose data can change depending on
> other external factors. It could change daily.
> Yes this second table could be an association but I would have
> preferred it not to be.

Well, then it really is two separate things, and it should be two
separate things. You are right. Update the second table every so often
with a scheduled task.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

Re: [Rails] Re: Most popular IDEs for Ruby on Rails development

by rubyonrailsin 0 comments
On Mon, Mar 15, 2010 at 11:22 AM, Norm Scherer
<normscherer@earthlink.net> wrote:
> There are only missing features until you add them.
>
> http://www.gnu.org/software/emacs/emacs-lisp-intro/emacs-lisp-intro.html
>
> Emacs can be made to do anything!

And people who shy away from that power aren't really programmers IMO.

IDEs make me touch my mouse way too much. The longer I can keep my
hands directly on the keyboard, the more productive I am. It's not
difficult to understand.


--
Greg Donald
destiney.com | gregdonald.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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] Problem with Getting Started with Rails

by rubyonrailsin 0 comments
I am working through the official Getting Started with Rails tutorial
http://guides.rubyonrails.org/getting_started.html#generating%20-a-controller

I am stuck on section 8.4 Generating a Controller. It suggests there
that this definition:
def index
@post = Post.find(params[:post_id])
@comments = @post.comments
end

S ould be used in com ents_controller.rb. Surely that would make
http://localhost:3000/comments work, but it gives the error
Couldn't find Post without an ID. That suggests a problem with the first
line of the definition. However that is what it says I should use in the
tutorial so I looked at post.rb and comment.rb and they are as directed.
Also checked routes.rb but all seems to be correct. Incidentally the
page http://localhost:3000/posts/1
works fine and displays comments which I have to enter with the terminal
as http://localhost:3000/comments/new gives the same error.

I have been tearing my hair out with this for 3 days. Can somebody
please point out what I am doing wrong.

Attachments:
http://www.ruby-forum.com/attachment/4577/index.html.erb

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] Re: Figuring out the relationships between models.

by rubyonrailsin 0 comments
I guess my question is this: if you declare that 'a has_one b', is it a
requirement that you must also state 'b belongs_to a' (i.e. can you have
a 'has_one' without a corresponding 'belongs_to' ?). If this requirement
holds true and I state that a prediction has_one race, then I must also
state that a race belongs_to a prediction. I may be mistaken here, but
this wouldn't allow me to retrieve all of the predictions associated
with a given race (and a race doesn't really belong to a prediction).

Mr. Ed :-)

Aldric Giacomoni wrote:
> Mr Horse wrote:
>> Thanks for the advice Aldric. This approach makes sense, but I get a
>> little confused with the relationship between predictions and races.
>>
>> A prediction has_one race, but does this mean that a race must belong_to
>> a prediction? While the first statement is correct (a prediction has_one
>> race), a race has many predictions associated with it. Is it possible to
>> state that a "race has_many predictions" as well as saying that a
>> "prediction has_one race"?
>>
>> I could say that a race has_many predictions and a prediction belongs_to
>> a race, but it makes more sense to me to think of a prediction having a
>> race as opposed to the other way around (a prediction belonging to a
>> race).
>>
>> Eddie
>
> A horse is a horse, of course of course... Oh, sorry. I was distracted.
>
> A prediction definitely doesn't belong to a race ;-)
> And a race doesn't belong_to a prediction because there's no foreign key
> for prediction in the race, is there?

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

Re: [Rails] Re: more than one table per model

by rubyonrailsin 0 comments
Okay here's why I want to do it.
The first table contains just data.
The second table will be a view whose data can change depending on
other external factors. It could change daily.
Yes this second table could be an association but I would have
preferred it not to be.

On Mon, Mar 15, 2010 at 10:18 AM, Aldric Giacomoni <lists@ruby-forum.com> wrote:
>
> I mean, maybe I'm completely off, but it sounds like you just want to
> create an extra table. What possible benefit could you derive from this,
> if the data won't be separate? I guess, if both your tables have 200
> fields, you would eventually derive an increase in read speeds if you
> don't need all the data.. But I can't think of another reason.
>
> You _can_ do it. Sometimes it's just a really bad idea, but you can
> always do it.
> --

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

Read More…

[Rails] Re: more than one table per model

by rubyonrailsin 0 comments
Frank Kim wrote:
> Hi everyone,
>
> I want to create a model that uses two tables for its data. Is that
> possible or just a bad idea? I don't want to do the has_one because I
> want to avoid the extra dereferencing.
I usually avoid doing this, but...
"I want to create a creature with two hands. Is that possible or a bad
idea? I don't want to link them to the same area of the brain because I
want to avoid putting five fingers on each hand".

I mean, maybe I'm completely off, but it sounds like you just want to
create an extra table. What possible benefit could you derive from this,
if the data won't be separate? I guess, if both your tables have 200
fields, you would eventually derive an increase in read speeds if you
don't need all the data.. But I can't think of another reason.

You _can_ do it. Sometimes it's just a really bad idea, but you can
always do it.
--
Posted via http://www.ruby-forum.com/.

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

Read More…

[Rails] Re: Figuring out the relationships between models.

by rubyonrailsin 0 comments
Mr Horse wrote:
> Thanks for the advice Aldric. This approach makes sense, but I get a
> little confused with the relationship between predictions and races.
>
> A prediction has_one race, but does this mean that a race must belong_to
> a prediction? While the first statement is correct (a prediction has_one
> race), a race has many predictions associated with it. Is it possible to
> state that a "race has_many predictions" as well as saying that a
> "prediction has_one race"?
>
> I could say that a race has_many predictions and a prediction belongs_to
> a race, but it makes more sense to me to think of a prediction having a
> race as opposed to the other way around (a prediction belonging to a
> race).
>
> Eddie

A horse is a horse, of course of course... Oh, sorry. I was distracted.

A prediction definitely doesn't belong to a race ;-)
And a race doesn't belong_to a prediction because there's no foreign key
for prediction in the race, is there?
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] more than one table per model

by rubyonrailsin 0 comments
Hi everyone,

I want to create a model that uses two tables for its data. Is that
possible or just a bad idea? I don't want to do the has_one because I
want to avoid the extra dereferencing.

For example

Model A
- attributes name in first table
- attribute phone_num in second table

Thanks,
Frank

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

Read More…

[Rails] Re: Figuring out the relationships between models.

by rubyonrailsin 0 comments
Thanks for the advice Aldric. This approach makes sense, but I get a
little confused with the relationship between predictions and races.

A prediction has_one race, but does this mean that a race must belong_to
a prediction? While the first statement is correct (a prediction has_one
race), a race has many predictions associated with it. Is it possible to
state that a "race has_many predictions" as well as saying that a
"prediction has_one race"?

I could say that a race has_many predictions and a prediction belongs_to
a race, but it makes more sense to me to think of a prediction having a
race as opposed to the other way around (a prediction belonging to a
race).

Eddie
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

Re: [Rails] Re: Most popular IDEs for Ruby on Rails development

by rubyonrailsin 0 comments
Greg Donald wrote:
On Fri, Mar 12, 2010 at 10:04 AM, Michael Schuerig <michael@schuerig.de> wrote:   
http://static.destiney.com/emacs_screen_shot.jpg       
There's one feature I've been missing in Emacs:     
 There are only missing features until you add them.  http://www.gnu.org/software/emacs/emacs-lisp-intro/emacs-lisp-intro.html    
Emacs can be made to do anything!
Read More…

[Radiant-Dev] Re: Providing an alternative Admin UI with enterprise look and feel but with the Radiant less is more concept!

by rubyonrailsin 0 comments
Temporarily removed, and made the beginners fault of renaming it
wrong.
Will be up again and noted here when done

On Mar 12, 9:39 am, rubybox <voorr...@gmail.com> wrote:
> I did not have time yesterday to post my mockups. So here they are...I
> would love to work together on this with some people, Let me know what
> you think!
> these mockups are an initial idea I had for years and copys some stuff
> from other CMS'ses around.
>
> @John: I wont open anymore topics on this subject.
> Everything can be discussed in this topic, since the topic you refer
> to was just to get an idea.
>
> Project Radiant-UI:
>
> http://github.com/rubytastic/radiant-UI
>
> On Mar 12, 3:32 am, "[Square Talent] Dirk Kelly"
>
>
>
> <dirk.ke...@squaretalent.com> wrote:
> > Hi Jordan, I don't feel there hasn't been a great deal of positive feedback
> > towards changing the user interface. I think it would be best we kept the
> > threads about this topic down to a minimum so that we can all focus on the
> > work that we're doing.
>
> > Your previous thread answers a lot of your questions.
>
> > Would really love to hear some feedback from the community on below
>
> > > mockups for the structure of a new admin UI that could benefit end
> > > users
>
> >http://groups.google.com/group/radiantcms-dev/browse_thread/thread/eb...
>
> > # Documenting how to remove certain portions of UI elements for
>
> > > regular users ( not designer or admin ) with code snippets so everyone
> > > can easily implement that
>
> >http://groups.google.com/group/radiantcms-dev/msg/ee1127c381686cc1
>
> > As Jim mentioned changing the interface is as simple as overwriting the view
> > files, and you would do this in an extension.
>
> > Cheers,
> > DK
>
> > On Fri, Mar 12, 2010 at 7:57 AM, rubybox <voorr...@gmail.com> wrote:
> > > As most of you read a few days back I posted this topic:
>
> > > Radiant admin UI:
> > >http://groups.google.com/group/radiantcms-dev/browse_thread/thread/eb...
> > > .
> > > I got some good feedback and idea on how everyone reacts on something
> > > like a new admin UI for radiant. So far I understand there is not much
> > > positive feedback on changing the default admin UI ( why would we its
> > > great of us developers, admins ) But I do feel there could be some
> > > improvements for regular users updating there website.  In that
> > > Currently I have some work done and things like login screen and page
> > > three, are all modified to have a more "enterprise" look and feel. I
> > > was not totally satisfied.
>
> > > Would really love to hear some feedback from the community on below
> > > mockups for the structure of a new admin UI that could benefit end
> > > users
>
> > > CONCEPT
> > > # Less web 2.0 look and feel and a bit more cleaner
> > > # Documenting how to remove certain portions of UI elements for
> > > regular users ( not designer or admin ) with code snippets so everyone
> > > can easily implement that
> > > # More enterprise look and feel
> > > # An alternative to the existing UI ( I plan to just code it so it
> > > works, it could be adapted to be a real alternative to the current
> > > Admin UI )
> > > # The UI exists in an empty extension that just holds the views,
> > > images are stored in a seperate folder in the /public directory
>
> > > Then now my initial thoughts and sketches for a new structure on the
> > > pages
> > > Please provide me with feebdack, suggestions on this! I will create
> > > the CSS and layout for this shortly on a Github repo  so you can
> > > download, share, contribute, etc
> > > *this will follow in a reply*
>
> > > --
> > > Radiant CMS Dev Mailing List
> > > Post:        radiantcms-dev@googlegroups.com
> > > Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
> > > Group Site:  http://groups.google.com/group/radiantcms-dev/

--
Radiant CMS Dev Mailing List
Post: radiantcms-dev@googlegroups.com
Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
Group Site: http://groups.google.com/group/radiantcms-dev/

Read More…

[Radiant-Dev] Re: Solving the Radiant theme and template problem

by rubyonrailsin 0 comments
Would be awsome and what we need to take Radiant to the next level,
please make possible all you great coders!
*hails to all! :)

On Mar 11, 9:01 pm, "M. Scott Ford" <sc...@vaderpi.com> wrote:
> On Thursday, March 11, 2010 1:31pm, "John Long" <johnwlong2...@gmail.com> said:
>
> > I agree Jim. Too many extensions are being forked to make them multi
> > site aware. Feel free to work on this in a branch.
>
> > I would suggest that it work off of a configuration key like
> > Radiant::Config['multi-site'] = true.
>
> +1 - sounds awesome

--
Radiant CMS Dev Mailing List
Post: radiantcms-dev@googlegroups.com
Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
Group Site: http://groups.google.com/group/radiantcms-dev/

Read More…

[Rails] New plugin added to add help text i.e. tooltip in rails http://ow.ly/1l7nF #plugin #rails #tooltip

by rubyonrailsin 0 comments
Hello All,

I just added a new rails_tooltip plugin on github that will help to add
help tooltip to html nodes ( table columns, text_fields, labels, etc. )

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

[Rails] Re: How to hide an object???

by rubyonrailsin 0 comments
Guille San wrote:
> Hello:
>> I didn't look at the very thoroughly, but this is a much better
>> approach:
>> http://electron.mit.edu/~gsteele/ffmpeg/
>
> Thanks for the link. This link could be very useful for other reserch
> that I´m done, but I think that not for this one I´m doing now, because
> my intention it´s to see tha camera images live(not live at all, but
> with 2 or 3 seconds of delay). My idea is see tha "video" directly in
> the webpage. Do you know if with other programming lenguage could be
> possible.

The language we're talking about here is JavaScript. The server-side
language has nothing to do with this. I'm not exactly an expert on this,
but I just have a feeling that attempting to push an image into the DOM
every half second, or even every full second, will create a lot of
problems for the browsers. I think it will look to the browser as if it
were a constant stream of data flowing into the page and it will
probably just keep consuming system resources with every new image.

I could be wrong, but from past experience I don't believe you'll get
satisfactory results with this approach. If you continue with this
design you'll need to monitor the system resource usage of various
browsers to see how they behave.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

Re: [Rails] Re: combine two has_and_belongs_to_many

by rubyonrailsin 0 comments
On 15 March 2010 14:05, eugenio <eugenio.modesti@gmail.com> wrote:
> thanks. i will try this, but i'm searching for something that can be
> used with some named_scope (based on the rights).

It would help if you mentioned that in your first post then, rather
than just asking how to determine @users.rights...


I tend to use something like this in my models:

named_scope :for_user, lambda { |user| scope_hash_for_user(user) }

private
def self.scope_hash_for_user(user)
case (user.role rescue nil)
when :admin
# see everything
when :client
# see nothing
{ :conditions => ["1 = 0"] }
when :customer_admin
# their company and below
{ :conditions => ["groupable_entities.id IN (SELECT company.id
FROM groupable_entities AS company
WHERE company.id in (?))",
user.company.self_and_descendants_ids] }
when :customer
# their company
{ :conditions => ["groupable_entities.id IN (SELECT company.id
FROM groupable_entities AS company
WHERE company.id = ?)", user.company.id] }
else
raise Aegis::PermissionError, "Unknown role"
end
end

In the controller I can call Model.for_user(current_user) to return
the items they are permitted to see, and combine it with Aegis for
permissions-checking on specific instances of objects in controllers
and views. Speaking to the developers of Aegis, they're hoping to
introduce some named-scope permissions method in their next release,
but depending on the timescale, I might look to see if CanCan handles
the problem better.

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

Read More…

[Rails] Re: Paperclip problem

by rubyonrailsin 0 comments
I am just unable to run, even though it seems everything is configured
(just like you have it).

Were you able to resolve this 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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] Re: Figuring out the relationships between models.

by rubyonrailsin 0 comments
Mr Horse wrote:
> Hi Guys,
> I'm trying to come up with a model layout for a simple enough race
> prediction app but am a little stuck. Basically, the app will allow
> users to enter their predictions for a number of races (20 races in
> total). When the races have been finished, I want to determine who
> predicted all of the race winners correctly, who got 19/20, who got
> 18/20 etc.
>
> Here's a summary of the players and their relationships:
>
> A User has one Betslip.
> A Betslip has many Predictions (one Prediction for each of the 20
> races).
> Each Prediction consists of one Race and one Racer (the predicted-to-win
> Racer).
> Each Race has a number of Racers.
> Each Race has one Winner (also a Racer).
>

User has_one :betslip
Betslip belongs_to :user
Betslip has_many :predictions
Prediction belongs_to :betslip
Prediction has_one :race
Prediction has_one :racer
Race has_many :racers
Race has_one :winner, :through => :racers

Racers .... Are separate? Unless each racer can only participate in one
race, in which case Racer belongs_to :race

I think that's basically what you're looking for.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] Configuring Paperclip on windows...

by rubyonrailsin 0 comments
I've been banging my head against rails in the last couple of days
trying to get paperclip to work in windows.

I have ImageMagick working. I have RMagick working (and tested it on
rails). I even configured paperclip to have the correct path to
identity.exe, however I keep getting an error that identity cannot be
executed.

--Dmitriy

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

Read More…

Re: [Radiant-Dev] Radiant ShopProducts - A bit of PrototypeJS love

by rubyonrailsin 0 comments
Sorry correction.
What your really trying to do is duplicate what happens when your element not get's clicked, not actually click the element.

What you really are trying to do is duplicate what happens when your element get's clicked. not actually click the element again.

Basically just create one function, and call it from both places.
 
On Mon, Mar 15, 2010 at 10:48 AM, Chris Rankin <rankin.devon@gmail.com> wrote:
DK,

There's not a good way to "click" an element. What you need to do is, extract the code that gets run when the product is clicked and put that it it's own function, instead of being in a behaviour. Then call that function from your behaviour, and also from the Ajax call.

What your really trying to do is duplicate what happens when your element not get's clicked, not actually click the element.

Make sense?






On Mon, Mar 15, 2010 at 3:21 AM, [Square Talent] Dirk Kelly <dirk.kelly@squaretalent.com> wrote:
Hi Guys.

This is really a post for radiant-ecommerce, but I need a wider range of potential readers.

In the interface for the radiant shop products http://github.com/squaretalent/radiant-shop_products-extnesion I have attempted to get the javascript up and going. I've been having a few teething issues and if I could get some advice that would be great.

Fire the click event for first-child
I'd like to have the first anchor within shop_products_list to have its click event fired after the list is repopulated, I'm having zero luck trying to find a way to do this.


General Feedback
If this code is terrible, I'd love to know about it. I'm sure I'm not hitting every best practice, but I am trying to evaluate as much existing code as I go. If you have any advice that would be great.

Cheers,
DK

--
Radiant CMS Dev Mailing List
Post: radiantcms-dev@googlegroups.com
Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
Group Site: http://groups.google.com/group/radiantcms-dev/


--
Radiant CMS Dev Mailing List
Post: radiantcms-dev@googlegroups.com
Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
Group Site: http://groups.google.com/group/radiantcms-dev/
Read More…

Re: [Radiant-Dev] Radiant ShopProducts - A bit of PrototypeJS love

by rubyonrailsin 0 comments
DK,

There's not a good way to "click" an element. What you need to do is, extract the code that gets run when the product is clicked and put that it it's own function, instead of being in a behaviour. Then call that function from your behaviour, and also from the Ajax call.

What your really trying to do is duplicate what happens when your element not get's clicked, not actually click the element.

Make sense?





On Mon, Mar 15, 2010 at 3:21 AM, [Square Talent] Dirk Kelly <dirk.kelly@squaretalent.com> wrote:
Hi Guys.

This is really a post for radiant-ecommerce, but I need a wider range of potential readers.

In the interface for the radiant shop products http://github.com/squaretalent/radiant-shop_products-extnesion I have attempted to get the javascript up and going. I've been having a few teething issues and if I could get some advice that would be great.

Fire the click event for first-child
I'd like to have the first anchor within shop_products_list to have its click event fired after the list is repopulated, I'm having zero luck trying to find a way to do this.


General Feedback
If this code is terrible, I'd love to know about it. I'm sure I'm not hitting every best practice, but I am trying to evaluate as much existing code as I go. If you have any advice that would be great.

Cheers,
DK

--
Radiant CMS Dev Mailing List
Post: radiantcms-dev@googlegroups.com
Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
Group Site: http://groups.google.com/group/radiantcms-dev/

--
Radiant CMS Dev Mailing List
Post: radiantcms-dev@googlegroups.com
Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com
Group Site: http://groups.google.com/group/radiantcms-dev/
Read More…

Subscribe feeds via e-mail

Blog Archive