Note that there are some explanatory texts on larger screens.

plurals
  1. PORubyctaculous Gem in Rails 4
    primarykey
    data
    text
    <p>On the offset - I am new to Rails, and struggling..</p> <p>I am trying to implement <a href="https://github.com/basgys/rubyctaculous" rel="nofollow">https://github.com/basgys/rubyctaculous</a> to my pins upload...</p> <p>I have a scaffold where the image (or pin) is uploaded to Amazon S3, and a return URL is stored in the Rails database.</p> <p>I then want it sent to Pictaculous (using the RubyGem mentioned) to grab the colour palette, which is stored in a "palette" column in my pins database to be read in the "show" view...</p> <p>Using strong parameters of course...</p> <p>I have added comments to the codes below.</p> <p>First of all I have created this parameter at the bottom of my controller.rb:</p> <pre><code>def palette_find @pictaculous = Pictaculous::Client.new colors = pictaculous.color_palette_for_image(:image) #This would be the image path from Amazon S3 stored in :image puts colors.inspect =&gt; [:palette] #How do I put the returning data into palette column??? end end </code></pre> <p>(this is the part I have no idea what I'm doing)</p> <p>I then want the parameter "palette_find" to activate during the "create" action in controller.rb after the "if @pin.save" which is where the database is updated with the image:</p> <pre><code>def create @pin = current_user.pins.build(pin_params) if @pin.save #I would assume you'd need to add something here involving "palette_find" because you'd have to have S3 confirmation before pulling from the database. if #Then perhaps do the if ____ ensuring that "palette_find" worked. redirect_to @pin, notice: 'Pin was successfully created.' else render action: 'new' end end </code></pre> <p>(Other info)</p> <p>The correct_user param looks like:</p> <pre><code>def correct_user @pin = current_user.pins.find_by(id: params[:id]) redirect_to pins_path, notice: "Not authorized to edit this pin!" if @pin.nil? end </code></pre> <p>And pin_params</p> <pre><code>def pin_params params.require(:pin).permit(:description, :image) end </code></pre> <p>Might I also need something like palette_params?</p> <pre><code>def palette_params params.require(:pin).permit(:palette) end </code></pre> <p>I hope someone can at least point me in the right direction...</p> <p>Owen</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload