Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 01:59
    amyspark starred hanami/hanami
  • Jan 18 22:11
    0exp starred hanami/model
  • Jan 18 22:05
  • Jan 18 21:18
    graudeejs edited #210
  • Jan 18 21:05
    graudeejs opened #210
  • Jan 18 20:48
  • Jan 18 16:22
    jodosha labeled #209
  • Jan 18 16:22
    jodosha assigned #209
  • Jan 18 16:22
    jodosha milestoned #209
  • Jan 18 16:22
    jodosha opened #209
  • Jan 18 16:21

    jodosha on unstable-cleanup

    WIP (compare)

  • Jan 18 11:42
    jodosha closed #165
  • Jan 18 11:42
    jodosha commented #165
  • Jan 18 11:42
    jodosha labeled #165
  • Jan 18 11:42
    jodosha unlabeled #165
  • Jan 18 11:42
    jodosha commented #165
  • Jan 18 11:39

    jodosha on router-inspector

    (compare)

  • Jan 18 11:39

    jodosha on unstable

    Router inspector (#208) (compare)

  • Jan 18 11:39
    jodosha closed #208
  • Jan 18 11:38
    jodosha ready_for_review #208
João Roberto
@jorbs
ok
adam12
@adam12_:matrix.org
[m]
In Ruby, numbers are essentially singletons but maybe something strange is going on.
João Roberto
@jorbs
using expect(last_response.status).to eq(200) I got the same error
adam12
@adam12_:matrix.org
[m]
Huh. Mystery.
@jorbs: does this work without rack-test? ie. can you curl it from command line?
What's the rest of the Gemfile? I doubt 401 would be a CSRF error but do you know if any CSRF protection is enabled?
João Roberto
@jorbs
yes. I can reach the endpoint.
~ curl -X GET http://localhost:2300/api/companies
{"data":[],"error":"Please supply valid tag"}
adam12
@adam12_:matrix.org
[m]
So it's just an issue with the spec...
João Roberto
@jorbs
adam12
@adam12_:matrix.org
[m]
Wouldn't be CSRF anyways with GET.
Can you put entire project up somewhere?
João Roberto
@jorbs
yup
adam12
@adam12_:matrix.org
[m]
I'll take a look maybe later? Just a few minutes to dinner here.
João Roberto
@jorbs

Can you put entire project up somewhere?

oh, sorry, I can't :(

adam12
@adam12_:matrix.org
[m]
OK. I can try to reproduce without it.
Presuming: fresh app, similar looking action, similar looking spec.
João Roberto
@jorbs
Thanks!
I also disable rake-cors, but no luck again
last_response.inspect returns this
#<Rack::MockResponse:0x00007fe3bb10f878 @original_headers={"X-Frame-Options"=>"DENY", "X-Content-Type-Options"=>"nosniff", "X-XSS-Protection"=>"1; mode=block", "Content-Security-Policy"=>"form-action 'self'; frame-ancestors 'self'; base-uri 'self'; default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self' https: data:; style-src 'self' 'unsafe-inline' https:; font-src 'self'; object-src 'none'; plugin-types application/pdf; child-src 'self'; frame-src 'self'; media-src 'self'", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"12"}, @errors="", @cookies={}, @status=401, @headers={"X-Frame-Options"=>"DENY", "X-Content-Type-Options"=>"nosniff", "X-XSS-Protection"=>"1; mode=block", "Content-Security-Policy"=>"form-action 'self'; frame-ancestors 'self'; base-uri 'self'; default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self' https: data:; style-src 'self' 'unsafe-inline' https:; font-src 'self'; object-src 'none'; plugin-types application/pdf; child-src 'self'; frame-src 'self'; media-src 'self'", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"12"}, @writer=#<Method: Rack::MockResponse(Rack::Response::Helpers)#append>, @block=nil, @body=["Unauthorized"], @buffered=true, @length=12>
Georgiy Odisharia
@krautcat

Hi there,

Is it good place to ask silly questions about Hanami for the person who do the stuff with Hanami as the hobby (I am too far from Web at my work)?

Moreover, it would be general questions about best practices in MVC-like stuff.

adam12
@adam12_:matrix.org
[m]
@krautcat: Sure.
adam12
@adam12_:matrix.org
[m]
@jorbs: I wasn't able to recreate your issue. I can share my repo if you want, but it's basically hanami new + an action like yours, modified the routes, and a spec like yours. It must be something with your environment.
João Roberto
@jorbs
yeah. I will create a brand new project and I see what happens.
thank you for your feedback!
Georgiy Odisharia
@krautcat

Okay, my first question is about placing code which uses Repository classes to create intermediate objects suited for consuming by controllers.

I have a lot of tables and they maps to the controller of my web application not good. I want to serve to my View not a lot of objects but a a few ones.

So I decided I need new class for it. Is it good practice to inherit from Entity class or not?

And where should I put the logic for transforming datum from database: new operations classes or as I've done in the Repository classes?

adam12
@adam12_:matrix.org
[m]
@krautcat: do you have code examples of what you're talking about? it's hard to picture.
Georgiy Odisharia
@krautcat

Sure, I will upload my test project to Github, don't you mind?

Or better to share code snippets here?

adam12
@adam12_:matrix.org
[m]
@krautcat: It doesn't matter. Whatever is easier for you.
Georgiy Odisharia
@krautcat

I think I will upload to Github to make it easier to move through code for you.

Here it is: https://github.com/krautcat/keyboards-warehouse

Also I have a question, is it good practice to create database on production by hand? I mean, no migrations, just all in plain SQL scripts, and also initial filling of the database with data via scripts and manually? So I shouldn't use migration feature in production?
Georgiy Odisharia
@krautcat
Currently my main worries are about Repository classes. Are they good place for code such located in https://github.com/krautcat/keyboards-warehouse/blob/master/lib/keyboards/repositories/assembled_switch_repository.rb ?
adam12
@adam12_:matrix.org
[m]
@krautcat: I might be inclined to just stick it in lib and call it SwitchAssembler or something. A plain PORO. Doesn't need to be "MVC".
If you need access to the repository, pass it in.
adam12
@adam12_:matrix.org
[m]

I don't personally manage production databases by hand. Everything has a migration and the migrations are run (but I run them manually and not during application boot).

For filling the data, I create seed "scripts" which might be production or might be for development. But these exist as classes in lib that I can test alongside the rest of the application.

Georgiy Odisharia
@krautcat

Thanks for the answers!

About migrations: is it good to write them in plain old SQL? Hanami's ORM have not so many features comparing to SQL obviously.

adam12
@adam12_:matrix.org
[m]

@krautcat: I'd say for migrations, it doesn't really matter. But once you write them in plain SQL you may lose some portability, if that matters to you (might not be able to run them on postgres AND sqlite).

The Hanami ORM for v1 is based on an older version of ROM, but below Hanami-Model and ROM is Sequel. If all else fails, you could get to Sequel and do what you need.

I write my migrations in Ruby because it saves me from remembering the nuances of specific database engines.
João Roberto
@jorbs

hi guys,

is there a command to add a new application to a hanami project?

adam12
@adam12_:matrix.org
[m]
@jorbs: bundle exec hanami generate app <app name>?
João Roberto
@jorbs
thanks!
João Roberto
@jorbs
@adam12_:matrix.org in order to not persist data between my tests, should I use a gem like database_cleaner or does Hanami have some mechanism to do that?
I couldn't find any info in the documention...
adam12
@adam12_:matrix.org
[m]
@jorbs: You can use database_cleaner. I don't think anything is in Hanami by default.
João Roberto
@jorbs
yup. Thanks!
Georgiy Odisharia
@krautcat

Hello there, trying to use assets but it seems I cannot make it work.

Placed my picture under assets/images/keyboards/sneakbox_design/prime_elise.jpg filename, used it with image helper as <% image 'images/keyboards/sneakbox_design/prime_elise.jpg' %> but image could not been loaded.

What could I did wrong?

Georgiy Odisharia
@krautcat
Full path from project root is apps/web/assets/images/keyboards/sneakbox_design/prime_elise.jpg.
Edouard
@inouire_twitter
You have to add this into your app application.rb file
     configure :development do
       ...
        assets do
          nested true
        end
    end
OR
Edouard
@inouire_twitter
use this (ignore directories) <% image 'images/prime_elise.jpg' %>