Ruby on Rails Thursday, August 29, 2013

On Aug 27, 2013, at 12:25 PM, Nick Khamis <symack@gmail.com> wrote:

> Hello Tamouse,
>
>
> >> It sounds now like you are setting that via an AJAX call.
>
> This is correct. We are using JQuery to manage the payload.
>
> >> Where you need to look is in the controller that is responding to that AJAX call in your Rails application,
> >> and look how it is determining the value it will send for the picture source url. That is likely where you
> >> need to use asset_url (without any ERB stuff) to set that part of the JSON payload that gets returned
> >> to the client.
>
> I know this makes total sense, the problem is I am too new to Rails (not the case for C, C++ or Lisp) to
> understand :). The value for wine.picture url is coming straight from the database:
>
> +----+----------------------------------------------+------+----------------+---------------------------------------+
> | id | name | year | country | picture |
> +----+----------------------------------------------+------+----------------+---------------------------------------+
> | 1 | CHATEAU DE SAINT COSME | 2009 | France | saint_cosme.jpg |
>
> If I understand you correctly, I would need to modify the picture field in the database to
> read asset_url('saint_cosme.jpg') without any of the ERB stuff "<%= %>"?

Do not modify the value in your database.

> Or if by controller you mean rails controller in the traditional sense, I have a very simple
> `pages_controller.rb` that contains the following:

I mean the controller that is being called by your AJAX request. It is entirely possible this in not your Rails app, but I would think it would be. You have to look at your javascript and find the AJAX call, then look at the url in that call to find the route it's seeking, and match that route to the controller. You can find out which routes map to controllers by running `rake routes`.


> class PagesController < ApplicationController
> def index
> end
> end
>
> As usual, forgive the noob, and thanks in advance!!!
>
> Nick.


--
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+unsubscribe@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/1D040D99-550A-4623-BC02-2B18DCEAF2F9%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment