Zanger02

Joined

10,990 Experience
107 Lessons Completed
0 Questions Solved

Activity

Posted in Setup MacOS 10.15 Catalina Discussion

zsh is now the default in Catalina. I wonder if using bash in your install script is part of the problem?

Good video

Chris just used Videos as an example. You can generate whatever you like.

No, it doesn't seem so.

@Edmundo Ramirez-Semprit - Chris just saved you a lot of time!!!

Jumpstart uses the pay pay gem & receipts gem to handle payments and billing. Setting up stripe was so easy!! Add stripe creds and add a plan using the plan stripe id. Chris has done a great job making payment setup really easy.

You can add the available endpoint to Stripe to have it process activity from your account.

You can update your payment details and cancel your subscription within the users dashboard.

Pretty sure Jumpstart sends a receipt via email automatically.

Posted in Actionable Errors in Rails 6 Discussion

Nice!

Posted in Symbols vs Strings Discussion

Glad to see you're adding more beginner episodes!

Posted in Problems with 'generate' command.

It's quite possible depending on your RubyMine settings. I had a similar issue with RubyMine in the past. One thing I'd check is to see what's in the Rubymine folder or whever is saves to. See if anything from your project is in RubyMine folder or it's subfolders.
Do you want to save the Squirrol project?

Posted in New Ruby/Rails site with documentation

Nice! Thanks for sharing.

Posted in Form Object for devise authentication

DId you solve this yet?

Posted in Problems with 'generate' command.

squirrool seems odd due to the output in the terminal. Question - is MacBooks-MacBook-Pro:squirrool giovanni$ your root folder? or the project folder?
You obviously created the controller, route and view.

Posted in What is wrong with my stripe configuration?

Thanks! Figaro is pretty simple to use.

"too many cooks in the kitchen is always a headache!" I couldn't have said it better.

Posted in What is wrong with my stripe configuration?

Thank you. I'm using figaro gem. The ENV var are in application.yml

There was an issue with the key. The key they provided worked for weeks then stopped working. They said the key was correct after chatting back and forth they generated a new one (without telling me) and it works now. Very frustrating. I rolled the keys previously hoping would fix the issue.

Posted in What is wrong with my stripe configuration?

Env variables are setup in application.yml. All my applications use this set up and have worked. All of a sudden it's giving me trouble.

application.yml

  STRIPE_PUBLISHABLE_KEY: pk_test_publishable_key
  STRIPE_SECRET_KEY: sk_test_secret_key

Posted in What is wrong with my stripe configuration?

Stripe isn't working anymore. When trying to create a new charge returns
the server responded with status 401

I followed stripes checkout docs to set up stripe. Stripe checkout

I have the stripe PUBLISHABLE_KEY: and SECRET_KEY: set up in application.yml

resources: charges

charges ctrl

def new
end

def create
  # Amount in cents
  @amount = 500

  customer = Stripe::Customer.create(
    :email => params[:stripeEmail],
    :source  => params[:stripeToken]
  )

  charge = Stripe::Charge.create(
    :customer    => customer.id,
    :amount      => @amount,
    :description => 'Rails Stripe customer',
    :currency    => 'usd'
  )

rescue Stripe::CardError => e
  flash[:error] = e.message
  redirect_to new_charge_path
end

stripe.rb

Rails.configuration.stripe = {
  :publishable_key => ENV['PUBLISHABLE_KEY'],
  :secret_key      => ENV['SECRET_KEY']
}

Stripe.api_key = Rails.configuration.stripe[:secret_key]

charges/new.html.erb

<%= form_tag charges_path do %>
  <article>
    <% if flash[:error].present? %>
      <div id="error_explanation">
        <p><%= flash[:error] %></p>
      </div>
    <% end %>
    <label class="amount">
      <span>Amount: $5.00</span>
    </label>
  </article>

  <script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
          data-key="<%= Rails.configuration.stripe[:publishable_key] %>"
          data-description="A month's subscription"
          data-amount="500"
          data-locale="auto"></script>
<% end %>

Posted in Why is viewer_id 0 on every video?

Thanks! Makes a lot of sense now.
Works great now! Thank you for your quick response.

Posted in Why is viewer_id 0 on every video?

Thanks Chris!
That fixed the issue returning 0.
I'm still seeing the integer in the view intead of the email.

Viewer: 2

I want the view to show
Viewer: user's email

Posted in Why is viewer_id 0 on every video?

The viewer_id always returns 0 after creating a video. A mentor creates a video with a user via hangouts. Mentor then creates the video on our website. Only the mentor and viewer should see the video. When the mentor creates the video she adds the viewer via a drop down menu listing emails.
In the view I want to see the email for the viewer_id and pass the viewer_id as an integer to the controller.
Not sure what I'm doing wrong.

class CreateVideos < ActiveRecord::Migration[5.1]
  def change
    create_table :videos do |t|
      t.string :title
      t.text :body
      t.integer :user_id
      t.integer :viewer_id
      t.string :url
      t.references :user, foreign_key: true
      t.timestamps
    end
  end
end
class VideosController < ApplicationController

 before_action :authorize_user

  def index
    @videos = Video.all
  end

  def new
    @video = Video.new
    @users = User.all 

  end

  def create
    @video = Video.create(video_params)
    @video.user = current_user

    if @video.save
      flash[:notice] = "Video was created successfully"
      redirect_to video_path(@video)
    else
      flash.now[:alert] = "There was an error saving the video. Please try again."
      render 'new'
    end
  end

  def show
    @video = Video.find(params[:id])
  end

  def edit
    @video = Video.find(params[:id])
  end

  def update
    @video = Video.find(params[:id])
    @video.assign_attributes(video_params)

    if @video.save!
      flash[:notice] = "Video was updated."
      redirect_to videos_path
    else
      flash.now[:alert] = "There was an error saving the video. Please try again."
      render :edit
    end
  end

  def destroy
    @video = Video.find(params[:id])

    if @video.destroy
      flash[:notice] = "\"#{@video.title}\" was deleted successfully."
      redirect_to videos_path
    else
      flash.now[:alert] = "There was an error deleting the video."
      render :show
    end
  end
end

private

def video_params
  params.require(:video).permit(:title, :body, :url, :viewer_id)
end

def authorize_user
   unless current_user.admin? || current_user.mentor? 
     flash[:alert] = "Please sign up as a Premium member"
     redirect_to welcome_index_path
   end
 end

Videos/new.html.erb

 <section>
  <div class="container-fluid">
    <div class="row">
      <div class="col-md-8">
     <%= form_for @video do |f| %>
       <div class="form-group">
         <%= f.label :title %>
         <%= f.text_field :title, class: 'form-control', placeholder: "Enter video title", autofocus: true %>
       </div>
       <div class="form-group">
         <%= f.label :body %>
         <%= f.text_area :body, rows: 4, class: 'form-control', placeholder: "Enter video body" %>
       </div>
       <div class="form-group">
         <%= f.label :url %>
         <%= f.text_field :url, class: 'form-control', placeholder: "Enter video link" %>
       </div>
       <div class="form-group">
         <%= f.label :viewer %>
         <%= f.select :viewer_id, options_for_select(@users.map(&:email)), class: 'form-control'  %>
         <!-- a collection of User objects and want to display each user’s email but send user_ids to the controller -->
       </div>
       <div class="form-group">
         <%= f.submit "Save", class: 'btn btn-success' %>
       </div>
     <% end %>
   </div>
 </div>
 <%= link_to "Back to videos listing", videos_path %>
 </div>
 </section>

console

#<Video:0x007fc262c86e88
  id: 9,
  title: "Nathan Alexander",
  body: "Mentor is Robin",
  user_id: 4,
  viewer_id: 0,
  url: "www.something"

Posted in Embed Youtube video in Rails app

I tried the above and it doesn't work. Where exactly do you place the youtube video id?

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.