Ryan Mindigo

Joined

1,050 Experience
1 Lesson Completed
1 Question Solved

Activity

I have a Rails site with a PWA and also a native app built w/ a wrapper. The site/app is for Hotel staff to communicate. Some of the staff speak and post in Spanish-only and some English-only. How can we help users translate the user posts from Spanish>English and vice versa in the app(s)?

Thanks Greg! You are prob right, I did spend 30mins trying to get to Ruby 3+ and Rails 7 but for some reason couldnt get to Ruby 3. Will try those commands next :)

Here is the full dump of what happens:

ryanmindigo@Ryans-MacBook-Air-2 Rails-Apps % rails new MyApp
Ignoring nokogiri-1.10.10 because its extensions are not built. Try: gem pristine nokogiri --version 1.10.10
Ignoring bindex-0.8.1 because its extensions are not built. Try: gem pristine bindex --version 0.8.1
Ignoring bootsnap-1.4.8 because its extensions are not built. Try: gem pristine bootsnap --version 1.4.8
Ignoring byebug-11.1.3 because its extensions are not built. Try: gem pristine byebug --version 11.1.3
Ignoring ffi-1.13.1 because its extensions are not built. Try: gem pristine ffi --version 1.13.1
Ignoring msgpack-1.3.3 because its extensions are not built. Try: gem pristine msgpack --version 1.3.3
Ignoring nio4r-2.5.4 because its extensions are not built. Try: gem pristine nio4r --version 2.5.4
Ignoring nokogiri-1.10.10 because its extensions are not built. Try: gem pristine nokogiri --version 1.10.10
Ignoring puma-4.3.6 because its extensions are not built. Try: gem pristine puma --version 4.3.6
Ignoring sassc-2.4.0 because its extensions are not built. Try: gem pristine sassc --version 2.4.0
Ignoring sqlite3-1.4.2 because its extensions are not built. Try: gem pristine sqlite3 --version 1.4.2
Ignoring websocket-driver-0.7.3 because its extensions are not built. Try: gem pristine websocket-driver --version 0.7.3
create

create README.md
create Rakefile
create .ruby-version
create config.ru
create .gitignore
create Gemfile
run git init from "."
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m
Initialized empty Git repository in /Users/ryanmindigo/Desktop/Rails-Apps/MyApp/.git/
create package.json
create app
create app/assets/config/manifest.js
create app/assets/stylesheets/application.css
create app/channels/application_cable/channel.rb
create app/channels/application_cable/connection.rb
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/javascript/channels/consumer.js
create app/javascript/channels/index.js
create app/javascript/packs/application.js
create app/jobs/application_job.rb
create app/mailers/application_mailer.rb
create app/models/application_record.rb
create app/views/layouts/application.html.erb
create app/views/layouts/mailer.html.erb
create app/views/layouts/mailer.text.erb
create app/assets/images
create app/assets/images/.keep
create app/controllers/concerns/.keep
create app/models/concerns/.keep
create bin
create bin/rails
create bin/rake
create bin/setup
create bin/yarn
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/cable.yml
create config/puma.rb
create config/spring.rb
create config/storage.yml
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/application_controller_renderer.rb
create config/initializers/assets.rb
create config/initializers/backtrace_silencers.rb
create config/initializers/content_security_policy.rb
create config/initializers/cookies_serializer.rb
create config/initializers/cors.rb
create config/initializers/filter_parameter_logging.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/new_framework_defaults_6_0.rb
create config/initializers/wrap_parameters.rb
create config/locales
create config/locales/en.yml
create config/master.key
append .gitignore
create config/boot.rb
create config/database.yml
create db
create db/seeds.rb
create lib
create lib/tasks
create lib/tasks/.keep
create lib/assets
create lib/assets/.keep
create log
create log/.keep
create public
create public/404.html
create public/422.html
create public/500.html
create public/apple-touch-icon-precomposed.png
create public/apple-touch-icon.png
create public/favicon.ico
create public/robots.txt
create tmp
create tmp/.keep
create tmp/pids
create tmp/pids/.keep
create tmp/cache
create tmp/cache/assets
create vendor
create vendor/.keep
create test/fixtures
create test/fixtures/.keep
create test/fixtures/files
create test/fixtures/files/.keep
create test/controllers
create test/controllers/.keep
create test/mailers
create test/mailers/.keep
create test/models
create test/models/.keep
create test/helpers
create test/helpers/.keep
create test/integration
create test/integration/.keep
create test/channels/application_cable/connection_test.rb
create test/test_helper.rb
create test/system
create test/system/.keep
create test/application_system_test_case.rb
create storage
create storage/.keep
create tmp/storage
create tmp/storage/.keep
remove config/initializers/cors.rb
remove config/initializers/new_framework_defaults_6_0.rb
run bundle install
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java.
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies........
sqlite3-1.6.9-x86_64-darwin requires ruby version >= 2.7, < 3.3.dev, which is incompatible with the current version, ruby
2.6.3p62
run bundle binstubs bundler
Could not find gem 'rails (~> 6.0.3, >= 6.0.3.4)' in any of the gem sources listed in your Gemfile.
run bundle exec spring binstub --all
Could not find gem 'rails (~> 6.0.3, >= 6.0.3.4)' in any of the gem sources listed in your Gemfile.
Run bundle install to install missing gems.
rails webpacker:install
Ignoring nokogiri-1.10.10 because its extensions are not built. Try: gem pristine nokogiri --version 1.10.10
Could not find gem 'rails (~> 6.0.3, >= 6.0.3.4)' in any of the gem sources listed in your Gemfile.
Run bundle install to install missing gems.

When I create a new Rails App it seems to create the files but throws quite a few errors re gemfiles can't locate. Here is a sample let me know if this helps:

Ignoring nokogiri-1.10.10 because its extensions are not built. Try: gem pristine nokogiri --version 1.10.10
Could not find gem 'rails (~> 6.0.3, >= 6.0.3.4)' in any of the gem sources listed in your Gemfile.
Run bundle install to install missing gems.

ryanmindigo@Ryans-MacBook-Air-2 Rails-Apps % bundle install
Could not locate Gemfile

Then when I try to run the server with Rails S get similar issue:

Ignoring nokogiri-1.10.10 because its extensions are not built. Try: gem pristine nokogiri --version 1.10.10
Could not find gem 'rails (~> 6.0.3, >= 6.0.3.4)' in any of the gem sources listed in your Gemfile.
Run bundle install to install missing gems.

When I try to create a new Rails App it fails. I am on Big Sur 11.3, Ruby 2.7.2, and when type rails-v shows 6.0.3.4 but also ignoring quite a few gems including nokogiri and 6-7 others. I have tried to move to Ruby 3+ by updating rbenv and several other approaches however just can't get to Ruby 3 even as an option. I am guessing there is mismatch between Ruby version and Rails version but not sure. Tried to update bundle, or gem pristine none of that worked.

Posted in Multitenancy with the Apartment gem Discussion

+1 to this

Posted in How do I migrate apartment gem to Heroku correctly?

will check it out thanks!

Posted in How do I migrate apartment gem to Heroku correctly?

I am getting same issue.

Posted in Group Chat with ActionCable: Part 5 Discussion

@chris, I just finished video #5 of the Chatrooms tutorial. Everything looks ok in terminal output, but when I hit 'enter' key after typing a message I still have to refresh browser to see the message appear. Here is repo: https://github.com/rmindigo/chat_demo_gorails Any ideas why message doesn't appear instantly? Terminal output below. Thanks!

[ActionCable] [User 12] Finished "/cable/" [WebSocket] for 127.0.0.1 at 2019-01-29 16:51:10 -0800
[ActionCable] [User 12] ChatroomsChannel stopped streaming from chatrooms:3
Started GET "/cable" for 127.0.0.1 at 2019-01-29 16:51:10 -0800
Started GET "/cable/" [WebSocket] for 127.0.0.1 at 2019-01-29 16:51:10 -0800
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? [["id", 12], ["LIMIT", 1]]
[ActionCable] [User 12] Registered connection (Z2lkOi8vY2hhdC9Vc2VyLzEy)
[ActionCable] [User 12] Chatroom Load (0.3ms) SELECT "chatrooms".* FROM "chatrooms" INNER JOIN "chatroom_users" ON "chatrooms"."id" = "chatroom_users"."chatroom_id" WHERE "chatroom_users"."user_id" = ? [["user_id", 12]]
[ActionCable] [User 12] ChatroomsChannel is transmitting the subscription confirmation
[ActionCable] [User 12] ChatroomsChannel is streaming from chatrooms:3
[ActionCable] [User 12] ChatroomsChannel#send_message({"chatroom_id"=>3, "body"=>"see my message"})
[ActionCable] [User 12] Chatroom Load (0.3ms) SELECT "chatrooms".* FROM "chatrooms" WHERE "chatrooms"."id" = ? LIMIT ? [["id", 3], ["LIMIT", 1]]
[ActionCable] [User 12] (0.1ms) begin transaction
[ActionCable] [User 12] SQL (0.8ms) INSERT INTO "messages" ("chatroom_id", "user_id", "body", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) [["chatroom_id", 3], ["user_id", 12], ["body", "see my message"], ["created_at", "2019-01-30 00:51:22.264530"], ["updated_at", "2019-01-30 00:51:22.264530"]]
[ActionCable] [User 12] (28.0ms) commit transaction
Message Load (0.4ms) SELECT "messages".* FROM "messages" WHERE "messages"."id" = ? LIMIT ? [["id", 49], ["LIMIT", 1]]
[ActionCable] [User 12] [ActiveJob] Enqueued MessageRelayJob (Job ID: b63d1b75-902b-47c9-b864-d6aec9495db6) to Async(default) with arguments: #<GlobalID:0x007f90e113e998 @uri=#<URI::GID gid://chat/Message/49>>
[ActiveJob] [MessageRelayJob] [b63d1b75-902b-47c9-b864-d6aec9495db6] Performing MessageRelayJob (Job ID: b63d1b75-902b-47c9-b864-d6aec9495db6) from Async(default) with arguments: #<GlobalID:0x007f90e1137f08 @uri=#<URI::GID gid://chat/Message/49>>
[ActiveJob] [MessageRelayJob] [b63d1b75-902b-47c9-b864-d6aec9495db6] Chatroom Load (0.2ms) SELECT "chatrooms".* FROM "chatrooms" WHERE "chatrooms"."id" = ? LIMIT ? [["id", 3], ["LIMIT", 1]]
[ActiveJob] [MessageRelayJob] [b63d1b75-902b-47c9-b864-d6aec9495db6] User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 12], ["LIMIT", 1]]
[ActiveJob] [MessageRelayJob] [b63d1b75-902b-47c9-b864-d6aec9495db6] [ActionCable] Broadcasting to chatrooms:3: {:username=>"bratPitt", :body=>"see my message", :chatroom_id=>3}
[ActiveJob] [MessageRelayJob] [b63d1b75-902b-47c9-b864-d6aec9495db6] Performed MessageRelayJob (Job ID: b63d1b75-902b-47c9-b864-d6aec9495db6) from Async(default) in 3.17ms
[ActionCable] [User 12] ChatroomsChannel transmitting {"username"=>"bratPitt", "body"=>"see my message", "chatroom_id"=>3} (via streamed from chatrooms:3)

Posted in Group Chat with ActionCable: Part 4 Discussion

Same error for me. Will just press on and hope things work when we addd ActionCable.

got the answer, needed to add one line to the new action in AccountsController

@account.users.build

Posted in How do I remove associated records?

have you tried this? or some variation of dependent: :destroy on the model associations

has_many :students, through: :attendances, source: :student, dependent: :destroy

https://guides.rubyonrails.org/association_basics.html

Posted in How update value which run from strong params??

Hello! I am building an app with Accounts/Users & Memberships via has_many through. I am using Devise and want to create a new user from 'accounts#new" via 'accepts_nested_attributes_for.'

When I fill out the form to create a new Account & User, the Account is being created, but no User. I am seeing 'unpermitted parameter: :user.'

I assume there is something missing in my Controller. Here is the terminal output and code below.

I am able to successfully create a new Account and User in console

 hey.memberships
  Membership Load (0.4ms)  SELECT  "memberships".* FROM "memberships" WHERE "memberships"."user_id" = ? LIMIT ?  [["user_id", 3], ["LIMIT", 11]]
 => #<ActiveRecord::Associations::CollectionProxy [#<Membership id: 1, user_id: 3, account_id: 6, created_at: "2018-12-30 20:43:07", updated_at: "2018-12-30 20:43:07">]> 

Any help would be greatly appreciated!

Parameters: {"utf8"=>"✓", "authenticity_token"=>"6eMcKYXDsP/XX+LyvCY2/yxnyWThWT3Upjc9WDAEF828iJ4Afdk3Z5X0DP8PKGJSVBR+MM6OxyITx9aFMM9MCw==", "account"=>{"name"=>"chesterfield", "user"=>{"email"=>"jason@aol.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}}, "commit"=>"Create Account"}
Unpermitted parameter: :user
   (0.1ms)  begin transaction
  SQL (0.5ms)  INSERT INTO "accounts" ("name", "created_at", "updated_at") VALUES (?, ?, ?)  [["name", "chesterfield"], ["created_at", "2019-01-01 17:15:55.817878"], ["updated_at", "2019-01-01 17:15:55.817878"]]
   (41.4ms)  commit transaction
Redirected to http://localhost:3000/accounts/12
Completed 302 Found in 46ms (ActiveRecord: 42.1ms)

AccountsController

 def new
    @account = Account.new
  end

     def create
    @account = Account.new(account_params)
    respond_to do |format|
      if @account.save
        format.html { redirect_to @account, notice: 'Account was successfully created.' }
        format.json { render :show, status: :created, location: @account }
      else
        format.html { render :new }
        format.json { render json: @account.errors, status: :unprocessable_entity }
      end
    end
  end

    def account_params
      params.require(:account).permit(:name, users_attributes: [:email, :password, :password_confirmation])
    end

Account Form

<%= form_with(model: account, local: true) do |form| %>
  <% if account.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(account.errors.count, "error") %> prohibited this account from being saved:</h2>

      <ul>
      <% account.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= form.label :name %>
    <%= form.text_field :name, id: :account_name %>
  </div>

  <div class="field">
    <%= form.fields_for :user do |f| %>
          <div class="field">
            <%= f.label :email %><br />
            <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
          </div>

          <div class="field">
            <%= f.label :password %>
            <% if @minimum_password_length %>
            <em>(<%= @minimum_password_length %> characters minimum)</em>
            <% end %><br />
            <%= f.password_field :password, autocomplete: "new-password" %>
          </div>

          <div class="field">
            <%= f.label :password_confirmation %><br />
            <%= f.password_field :password_confirmation, autocomplete: "new-password" %>
          </div>
    <% end %>      
  </div>

  <div class="actions">
    <%= form.submit %>
  </div>
<% end %>

Models

class Account < ApplicationRecord
    has_many :memberships
    has_many :users, through: :memberships
    accepts_nested_attributes_for :users
end

class User < ApplicationRecord
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable
  has_many :memberships
  has_many :accounts, through: :memberships     
end

class Membership < ApplicationRecord
  belongs_to :user, optional: true
  belongs_to :account, optional: true
end

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2024 GoRails, LLC. All rights reserved.