Activity
Hmm, I wonder why then the string was ""
then. I assumed that's what it would do when there was no attachment.
Try just printing out the image_url
on the page directly. Once you figure out what's missing there, then you can add it to the style attribute.
You can always throw a byebug onto the page so you can fiddle with it while it's rendering.
I think you just want something like:
def index
query = params[User.where(account_id: Current.account)] || "*"
args = {}
args[:account_id] = Current.account.id
args[:first_name] = params[:first_name] if params[:first_name].present?
args[:languages] = params[:languages] if params[:languages].present?
@users = User.search query, where: args,
aggs: {
first_name: {},
languages: {}
}
end
Well, it looks like you don't have an image attached. That will obviously only work if there is an image attached. 🧐
Assuming you're using ActiveStorage?
Should be like:
style="background: url('<%= image_url @creator.header_image %>');"
Posted in Model/concerns question
Great topic for me to record a screencast on.
Modules really just add methods to a class, so you can define both class and instance methods in the module and they're accessible as if they were defined in the class.
The module in your example adds an instance method, so you could call it inside any method in your class.
class Subject < ActiveRecord::Base
include CapitalizeIt
def name
capitalize_title(self.title)
end
end
If you were to add a class method in the module, then you could call it outside of a method because code that runs there is running inside the class, not an instance.
Methods like scope
belongs_to
and has_many
are all examples of class methods.
acts_as_taggable_on works with Rails 6. I've been using it for ages, should do what you need. 👍
Bruno,
Make sure you add the account_id in your search's where
so it filters down. ElasticSearch is going to keep a separate indexed copy of your database, so when you search it, you need to apply the same types of filters as you would in your db queries.
Posted in Subscriptions with Stripe Discussion
That's up to you I'm pretty sure. They do allow you to configure their emails for various things like failed payments though. You can find all those email options in the Settings tab on Stripe.
Posted in Flatpickr with "Present" value as well.
Yep, and I don't know that you necessarily need the currently working boolean in the database. You can just add some methods in your model to delegate to the end_date column.
class Job
def currently_working?
!end_date?
end
end
Then you can just use that method to set the checked
attribute on the checkbox by default when editing.
Posted in Flatpickr with "Present" value as well.
Hey Gerard,
I would probably use Javascript to do two things when checked:
- Hide/show the end date field
- Clear the value for the date fields
Flatpickr write the selected value to a form field, so it can be submitted to the server. That's the field you'll want to clear out in the JS.
Then just make sure your end date field is marked as optional in your database so it can be null.
Posted in Login with Facebook Discussion
Hey Olivia! You might be able to add this to the User model so that they're always marked as "remember me" to extend the logins for as long as possible.
class User
def remember_me
true
end
end
You can also configure Devise to have a longer cookie expiration which may help.
I'm actually going to be doing sort and search/filter for some Jumpstart Pro upgrades to the base scaffolds soon, so I'll probably dig into this in a related way, just maybe not with ElasticSearch as the backend specifically. May do pg_search instead.
Thanks for the info on webcam uploads Max!
I also just finished recording a screencast on using Uppy with ActiveStorage, so that episode should go live in the next week or so.
Posted in EleasticSearch and Indexing Empty Models
Looks like this: https://github.com/ankane/searchkick/issues/793
I don't think that's right. We're using fixtures in this episode in our system tests. We're signing in as fixture users and visiting project fixtures for example.
Posted in Friendly URL's question
Hey Nelson,
The name of the model helps make routing way easier, so that's why it's done that way. Here's an example of why.
You might have a /sign_up route, but if you weren't careful, "sign_up" can easily get treated as a topic, which you don't want.
To do this, you'll just write your own custom routes.
get "/sign_up"
get "/:topic/:forum/:post"
get "/:topic/:forum"
get "/:topic"
This way, sign up should get interpreted first, instead of it being treated as a topic. And the rest of the routes are catch-alls to treat everything else as if it were a topic and so on. Those routes have to be the last in your routes file in order to not override the other routes.
Have any of you guys checked out this repo? https://github.com/Sology/uppy-activestorage-upload
Posted in Get Jumpstart Pro
Hey Martin!
I wish I could, but it's a lot of work to maintain and I spent like 9 months building it, so I'm not able to offer any discounts. It's already probably cheaper than what I should be charging for it, so in the future I may raise the price a bit. I just want to make it as accessible to everyone as I can, but without burning myself out working on it.
Thank you for the heads up that it wasn't working! I appreciate you!
Also should mention, I found that information here: https://www.elastic.co/guide/en/elasticsearch/reference/7.3/bootstrap-checks.html#_forcing_the_bootstrap_checks