Arnas Klasauskas

Joined

350 Experience
0 Lessons Completed
0 Questions Solved

Activity

Thank you.

This worked, but I'm still facing an issue with the Tasks::CommentsController, since I can't use Task.friendly.find(params[:task_id]).

My method currently looks like this, but it throws an error, that it can't find the id when using params[:id] and when I use params[:task_id], I get the error undefined method task_url for Class.......

This is the method I'm using:

def set_commentable
 @project = Project.friendly.find(params[:project_id])
 @tasks = @project.tasks.order(:tag)
 @commentable = @tasks.friendly.find(params[:task_id])
end

I have nested routes so everytime I try to render the form I get an error.

How should I change the form to work with nested routes? This line throws an error, since it can't find tasks_comments_path

<%= form_with model: [commentable, Comment.new], local: true do |form| %>

My routes look like this:

  resources :projects do
    resources :project_steps, path: "step", only: [:show, :update]
    resources :tasks do
            resources :comments, module: :tasks
        end
    resources :reviews, only: [:create, :destroy]
  end

I'm currently trying to create a new rails app. I can easily do this with rails new app --database=postgresql but when I change the database.yml, I'm using the same user for every application for example postgres. Therefore all applications share the same database user.

Then when I try to install a gem in my new application it says, that the gem is already installed.

Therefore I created a new user, but this didn't really work. I can create a new rails app with the new user but it throws erros that I need to to install, bundler, that it cant find the bundle folder and so on.

Do have any guidance on this ? I'm using Ubuntu 18.04 on Windows.

I'm currently adding stripe to my application. I think stripe form doesn't look that good, therefore I would like to beautify the form.

I found this gem https://rails-assets.org/#/components/card which does render the user input in a creditcard. I remember that a few months ago I watched a video where someone implemented this, but later deleted the card form, since it wasn't save to use with stripe.

I'm currently unaware why this shouldn't be save to use. Probably someone can help me out ?

Posted in How do I add HTTParty to ActiveJob ?

I'm currently trying to make a GET request with ActiveJob. It looks like everything is working, but somehow the GET request isn't saving in my database.

This is my TypeformJob:

  def perform(current_user)
    response = HTTParty.get("https://api.typeform.com/forms/XXXXX/responses?page_size=25&query=#{current_user.hash_id}",
      headers: { "Authorization" => "Bearer #{@token}"})
    if response.code.to_i == 200
      items = response.parsed_response["items"]
      items.each do |item|
        @order = current_user.orders.find_or_create_by(landing_id: item["landing_id"]) do |order|
          order.landing_id = item["landing_id"]
          order.order_number = item["hidden"]["order_number"]
          order.moduls = item["hidden"]["moduls"]
          order.project = item["hidden"]["project"]
          order.category = item["hidden"]["nickname"]
          order.price = item["hidden"]["price"]
          order.total = item["hidden"]["total"]
          order.summary = item["answers"][0]["text"]
          order.payment = item["answers"][1]["choice"]["label"]
          order.number = item["answers"][2]["number"]
          order.day = item["answers"][3]["date"]
          order.contact = item["answers"][4]["choice"]["label"]
        end
      end
    else
      p response
    end
  end

My OrdersController:

  def get_requests
    TypeformJob.perform_later(current_user)
  end

The console responses with this:

[ActiveJob] [TypeformJob] [2560dd37-cc4c-4cc3-95e9-5787b65e1960]   Order Load (0.4ms)  SELECT  "orders".* FROM "orders" WHERE "orders"."user_id" = $1 AND "orders"."landing_id" = $2 LIMIT $3  [["user_id", 4], ["landing_id", "16c950ff40b24dc41300a5ceb6cb4e7e"], ["LIMIT", 1]]
[ActiveJob] [TypeformJob] [2560dd37-cc4c-4cc3-95e9-5787b65e1960]   ↳ app/jobs/typeform_job.rb:12
[ActiveJob] [TypeformJob] [2560dd37-cc4c-4cc3-95e9-5787b65e1960]    (0.5ms)  BEGIN
[ActiveJob] [TypeformJob] [2560dd37-cc4c-4cc3-95e9-5787b65e1960]   ↳ app/jobs/typeform_job.rb:12
[ActiveJob] [TypeformJob] [2560dd37-cc4c-4cc3-95e9-5787b65e1960]    (0.2ms)  ROLLBACK
[ActiveJob] [TypeformJob] [2560dd37-cc4c-4cc3-95e9-5787b65e1960]   ↳ app/jobs/typeform_job.rb:12
[ActiveJob] [TypeformJob] [2560dd37-cc4c-4cc3-95e9-5787b65e1960] Performed TypeformJob (Job ID: 2560dd37-cc4c-4cc3-95e9-5787b65e1960) from Async(default) in 1007.91ms

Any thoughts on this? I'm not sure where the ROLLBACK does come from

Posted in How do I add radio buttons to devise signup form ?

I'm currently trying to add radio buttons to the devise signup form, the problem is that I dont know how I should write the migration, should it be a boolean, an integer or a string ?

The user can choose between two options, therefore I don't know how to proceed.

This is the current html code:

          <div class="row">
            <div class="col">
              <div class="form-group rounded bg-white p-2 border">
                <div class="custom-control custom-radio">
                  <input type="radio" id="course-radio-beginner-1" name="course-radio-1" class="custom-control-input">
                  <label class="custom-control-label" for="course-radio-beginner-1">Gründer</label>
                </div>
              </div>
            </div>
            <div class="col">
              <div class="form-group rounded bg-white p-2 border">
                <div class="custom-control custom-radio">
                  <input type="radio" id="course-radio-advanced-1" name="course-radio-1" class="custom-control-input">
                  <label class="custom-control-label" for="course-radio-advanced-1">Unternehmen</label>
                </div>
              </div>
            </div>
          </div>

Posted in Setup Windows 10 Discussion

Hey Chris I'm getting the following error:
PG::ConnectionBad (could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
):

Posted in How do I add multiple subscriptions to one user ?

Hey Chris,
I'm currently working without a Model, therefore it's a bit tricky, but I guess I'll be able to handle this.

Just this last step isn't working fully to my intention...

if current_user.subscription_id?
Stripe::SubscriptionItem.create(
subscription: current_user.subscription.id,
plan: plan.id
)
else
subscription = customer.subscriptions.create(
plan: plan.id
)
current_user.update(
stripe_id: customer.id,
subscription_id: subscription.id
)
end

This works when I add a new plan to the subscription, but it throws an error when I subscribe to the same plan twice. Stripe::InvalidRequestError (Cannot add multiple subscription items with the same plan: XXXXXX

Posted in How do I add multiple subscriptions to one user ?

I'm able to assign multiple subscriptions to a user, but the problem is that everytime I assign a new subscription to a user, I'm overriding the subscription_id.

I can still show the user all his subscriptions through Stripe::Subscription.list(customer: current_user.stripe_id), but it's not possible to show a specific subscription, just the last one that was created.

How can I overcome this ?

I'm currently trying to implement Stripe. I already did it before, but Stripe made some changes for European Countries. Now I would like to implement subscriptions. I'm quite getting a headache wrapping my head around PaymentIntent, Products, Plans and Subscriptions.

Probably you could make a new video or even a course explaining the Stripe setup for european countries.

Posted in Subscriptions with Stripe Discussion

Hey there!
I'm currently asking myself, how you would implement a plan dynamically? You would need to create a Plan with plan = Stripe::Plan.create(plan: project.name) and so on. Afterwards you would call subscriptions on the plan, like plan.subscriptions.create ?

It would be nice to get more detailed information.