Martin McDermid
Joined
Activity
Posted in Simpleform association with images!
It's been a long week! :) Thanks for taking the time anyway, it's very much appriciated!
You also have a weird ability to create videos which contain stuff I'm working with at the time! You think you could point me in the right direction with this? https://stackoverflow.com/questions/44664847/using-impressionist-with-chartkick-displaying-user-articles-impressions-in-gra
Posted in Simpleform association with images!
It was just me being an idiot Chris, I didn't create the join table for messages and vehicle_images. Schoolboy error.
Thanks again.
Posted in Simpleform association with images!
Hmm, when I don't add any images I get 'VehicleImage(#70203987369520) expected, got String(#47143662444640)'
Posted in Simpleform association with images!
Thanks for taking a look Chris.
I do have message_id on Buckets.
class CreateBuckets < ActiveRecord::Migration
def change
create_table :buckets do |t|
t.integer :message_id
t.datetime :expires_at
t.integer :vehicle_id
t.integer :vehicle_images
t.timestamps null: false
end
end
end
Here is the various bits 'n bobs in gist
https://gist.github.com/MartinMcDermid/58c46474865fe25f95dd65f1485e5477
Thanks again!
Posted in Simpleform association with images!
Hi Chris,
I'm wondering if you could help. I'm currently building a form that'll send out a SMS with twilio, and i'm looking to send details of a vehicle out at the same time, specifically the images of that vehicle. I have the form working perfectly except selecting which images are to be sent. If i run what i've put below I get 'can't write unknown attribute message_id
'
<%= simple_form_for [@vehicle, Message.new] do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :to %>
<%= f.input :company %>
<%= f.input :body %>
<%= f.association :vehicle_images,
:as => :check_boxes,
item_wrapper_tag: :div,
item_wrapper_class: "image-select",
:collection => @vehicle.vehicle_images.order(:id),
:label => false,
:inline_label => false,
:include_blank => false,
:input_html => {multiple: true},
:label_method => lambda { |b| image_tag(b.image.url(:thumb)) },
value_method: :id
%>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>
def create
@vehicle = Vehicle.find(params[:vehicle_id])
@message = Message.new(message_params)
@message.vehicle_id = @vehicle.id
respond_to do |format|
if @message.save
@bucket = Bucket.new
@bucket.message_id = @message.id
@bucket.vehicle_id = @vehicle.id
@bucket.vehicle_images = params[:message][:vehicle_image_ids]
@bucket.save!
#byebug
format.html { redirect_to vehicle_messages_path(@vehicle), notice: 'Message was successfully created.' }
format.json { render :show, status: :created, location: @message }
else
format.html { render :new }
format.json { render json: @message.errors, status: :unprocessable_entity }
end
end
end
Is there anyting silly I'm missing from what you can see here? I'm rushing out but if you need more info to give any feedback, just let me know.
Thanks very much, it's appriciated!
Posted in Saved messages as HTML
That's brilliant Chris, works perfectly! :) Thanks very much. Been playing around with it all night but I'm quite the novice when it comes to JS!
Posted in Saved messages as HTML
Hi Chris,
I'm wondering, on your episode https://gorails.com/episodes/message-templates, would it be possible to have one of the saved messages as HTML? I've tried entering <h1>test</h1><p>this is a test</p>
but nothing appears once selected (just some whitespace). Plain text works fine.
This is what I see in the source:
<option data-body="<h1>test</h1><br><p>this is a test</p>" value="1">Test</option>
It's obviously formatting it, but am I able to disable this?
Thanks Chris, I appreciate it.