Activity
you can do
<%= truncate(blog_post.content.to_plain_text, length: 130) %>
Brendan, a little late but heres a simple approach without using any gem. https://dev.to/kolide/a-rails-multi-tenant-strategy-thats-30-lines-and-just-works-58cd
I wish this would get merged in https://github.com/hotwired/turbo/pull/525
well figured it out you can do this just incase someone is having the same issue. Its just inserting a blank value at 0.
<%= turbo_stream.update @target do %>
<%= options_for_select @team_users.map { |k,v| ["#{k.first_name} #{k.last_name}", v = k.id] }.insert(0, "") %>
<% end %>
step further if you want to show some text but have no value for that option you can also do the following:
<%= turbo_stream.update @target do %>
<%= options_for_select @team_users.map { |k,v| ["#{k.first_name} #{k.last_name}", v = k.id] }.insert(0, ["Please select...", ""]) %>
<% end %>
Basically adding this at the end .insert[0, ["please select...", ""]
Is there a way to include blank when doing this? I have tried several variations (not related to country/state but team/user) but haven't had any success.
<%= turbo_stream.update @target do %>
<%= options_for_select(@team_users.map { |k,v| ["#{k.first_name} #{k.last_name}", v = k.id] }, include_blank: true) %>
<% end %>
Downloading / emailing a file should be more so a background job so you don't block other processes (app) specially if its a large file.
How does this work if say you have a mobile app that's a wrapper for your WebViews, compared to someone using safari/chrome on their mobile device?
Posted in How to use Hotwire in Rails Discussion
You using link_to or button_to ?
Do you mean like a flash notice? you can do it as a
function myFunction() {
setTimeout(function(){ alert("Hello"); }, 3000);
}
Posted in What is the best way to learn React JS?
https://wesbos.com/courses has a beginner and advanced React courses thats up-to-date.
https://wesbos.com/beginner-javascript. Take this course as well: https://javascript30.com/
Hey - this is all I had to do to get it working. If you're on slack I can send you a video of how that looks. https://gist.github.com/tabishiqbal/e8959c594d25c5306255e276daf9f240
Hey Matthew, kinda old but did you figure this out? From what I gather you're trying to have one drop down where when the user selects a value it updates values in another dropdown. If so hit me up as I have a working example of this.
SR does allow you to update the whole page, selector or nothing. For the whole page morph it will re-run the controller action. Not sure how it would work with Calendar events but more info can be found here: https://docs.stimulusreflex.com/v/pre-release/rtfm/morph-modes
How does this work with someones avatar thats uploaded using activestorage? I get the following url for the image
http://example.org/rails/active_storage/representations/redirect/...../chewy.jpeg
where the example.org was set in application_controller_renderer.rb
. Even after replacing it to "localhost" it still doesn't work. When you do a full page reload all the avatars show up.
Not going to lie I hear some beeping sound or popping sound and then raise my right or left arm depending on which ear I heard it in. Am I the only one hearing this or what? It's low key making me do the hearing test...
Posted in How to use Hotwire in Rails Discussion
do you have a /assets/javascripts/libraries folder? installed it for asset pipeline or webpack?
Posted in How to use Hotwire in Rails Discussion
prob the best xmas gift he got...
Howdy. You can have your static marketing pages in the same app if you like. The way I have done it is have routing constraints. IE
class MarketingSite
def self.matches?(request)
request.subdomain.blank? || request.subdomain == "www"
end
end
class App
def self.matches?(request)
request.subdomain.present? && request.subdomain == "app"
end
end
Rails.application.routes.draw do
constraints(MarketingSite) do
root "static#index"
get "/pricing", to: "static#pricing"
get "/contact", to: "static#contact"
end
constraints(App) do
....routes...
end
end
And then you will have a views/layouts/static.html.erb
which will be used by the static controller like so:
class StaticController < ApplicationController
layout "static"
end
You can let people sign up using devise but accept a nested attribute for company and get the company name on the signup form as well. Company has many users and user belongs to company. Another thing is having a join table so
Company: has_many company_users
CompanyUser: belongs_to company, belongs_to user
User: has_many :company_users, belongs_to company, through: company_user