Activity
Did you mean greater_than_or_equal_to: 0
?
The code right now wouldn't allow the quantity to ever be 0, but that seems like something you'd want to support.
Posted in What is wrong in my script?
Your new_response action sets up answers in memory, but your create_response action is the one to save it.
However you're rendering create_response.html.haml where the error came from. Seems like you're looking at the wrong view.
Possibly fixed by doing the following:
def create_response
@survey = Survey.find(params[:id])
@response = @survey.build(response_params)
@response.user = current_user
if @response.save
redirect_to @response
else
render action: :new_response
end
end
That'll redirect to the response if it saves successfully and mimics the normal create action.
Hey Lunik,
It sounds like SimpleMDE is not getting attached to the hidden reply comment forms.
For GoRails, I had to do this, so it applies SimpleMDE to any visible forms and then it also applied it when you click the Reply link.
Apologizes for the messy code, this could use some refactoring. :)
simplemde = []
cleanupSimpleMDE = ->
# Clean up if already exists
if simplemde.length > 0
for editor in simplemde
editor.toTextArea()
simplemde = []
addSimpleMDE = (field) ->
editor = new SimpleMDE({
autoDownloadFontAwesome: false,
element: field,
toolbar: ["bold", "italic", "heading", "|", "code", "quote", "unordered-list", "ordered-list", "clean-block", "|", "link", "image", "|", "preview", "side-by-side", "fullscreen", "guide"],
spellChecker: false
status: false
})
simplemde.push(editor)
return editor
@setupEditors = ->
for editor in $(".simplemde:visible")
addSimpleMDE(editor)
$("[data-behavior='show-comment-form']").on "click", (e) ->
e.preventDefault()
reply_link = $(this)
reply_link.hide()
form = reply_link.parents(".forum_post").first().find("[data-behavior='comment-form']")
form.show()
addSimpleMDE(form.find("textarea")[0])
$(window).on 'popstate', cleanupSimpleMDE
$(document).on 'turbolinks:before-visit', cleanupSimpleMDE
$(document).on 'turbolinks:load', @setupEditors
Posted in Setup MacOS 10.14 Mojave Discussion
I haven't experienced it myself, but looks like there's some info on StackOverflow https://stackoverflow.com/questions/51270680/brew-wont-upgrade-on-mojave
Sure promises a lot for very cheap! I'd be curious to hear about how that experience goes.
If it's anything like DigitalOcean Spaces where it's API compatible with S3, then you can just change the host that they're going to.
I covered that a couple times in the past with DO Spaces:
https://gorails.com/episodes/digital-ocean-spaces-with-rails
https://gorails.com/series/direct-uploads-to-amazon-s3
You should then just be able to change the domain / host to point to Wasabi like we do here for Spaces, set the CORS config (if you're doing direct uploads, not needed if you're uploading to Rails and having Rails upload to storage) and be set.
Sweet, thanks for sharing that! Makes a lot of sense to use any built-in functionality that you can with ElasticSearch. This is a good improvement.
Posted in Search Filters/Report Generator
You can search multiple models at once with Searchkick by doing the following:
Searchkick.search "milk", index_name: [Product, Category]
And you can also customize the search_data
method on the model to include attributes from associated models.
This example builds up a string to index of all the tags stored in an association on the record.
def search_data
{
name_tagged: "#{name} #{tags.map(&:name).join(" ")}"
}
end
Hey zino,
A text column should work just fine. Rails will escape strings by default, which is what it will think it is given it's a text column.
When you render it out, you'll need to make sure it's rendered as raw values instead of as a string.
Something like <%= @record.column.html_safe %>
which would flag it as safe string to render directly without escaping.
The exact way you do that in your response will depend a bit upon which library you're using to render the JSON response, but that's the gist of it.
Posted in New Site Design!
Thanks Nick and Erik! I spent all weekend building it and am really happy with how it turned out.
If you guys notice any bugs, let me know! I think I had to edit almost every single view so I'm sure I missed something here or there.
Posted in Rails Application Templates Discussion
You'll have to view the Rails logs on Heroku, not the HTTP logs, to find the actual error.
Absolutely unacceptable Nick.
🤣 Just teasing!
If you edit the migration, you'd have to do a rollback to undo that migration and then re-run it. Obviously that'd blow away a bunch of data, so to add trackable at a later time you'll want to just create a new migration to add those columns separately.
Posted in Non-series episode list?
No idea, but sounds about right. I also just might make some new series and make sure they all land in something.
Posted in Non-series episode list?
No, but that's a good idea. Every episode can optionally belong to a series, so if you primarily used the Series page to find stuff to watch, you'd miss out on the others. Maybe I'll make a special series of un-series'd episodes or something. :)
It's just an install of Bootstrap and Devise, both of which I've covered in other episodes. Just search for them and you'll be up to speed!
You might need to build your own storage plugin for Shrine if your SMB share isn't mounted as a disk somewhere.
Sounds like you could simply change your form on update to set the new field and hide the old one.
Hey James,
Have you seen this episode? This runs transcoding in a background job after upload: https://gorails.com/episodes/shrine-background-and-video-transcoding
Yep, you certainly could. If you need those features it'd be great. Otherwise, there's not a whole lot of difference.
Hey Afolabi,
It should be as simple as using SQLs group and sum functionality. For example:
Order.where("created_at BETWEEN ? AND ?", 1.month.ago, Time.zone.now)group(:currency).sum(:charged_fee)
{"CAD"=>82, "NGN"=>20, "USD"=>143, "YEN"=>40}
Order.where("created_at BETWEEN ? AND ?", 1.month.ago, Time.zone.now)group(:currency).sum(:network_fee)
{"CAD"=>"23", "NGN"=>"40", "USD"=>"60", "YEN"=>"30"}
Posted in integrating stimulus with ruby on rails
app/javascript/controllers
It creates an example controller in there when you install stimulus with webpacker. rails webpacker:install:stimulus