http://amberframework.org - Questions? Post on StackOverflow and contribute to community knowledge! https://stackoverflow.com/questions/tagged/amber-framework - IRC? Share your chat messages across http://webchat.freenode.net/?channels=#amber
drujensen on master
reset back to master (compare)
drujensen on stable
drujensen on stable
drujensen on v0.36.0
drujensen on master
Bumped version number to v0.36.… (compare)
drujensen on crystal-0.36.0
sorry, clarifying: query for "tags contains X" for example, please and thank you
@vectorselector I don't know if it is the best approach but what I do is create View models with a select_statement that does the joins on the relevant tables which is then easy to filter with #all() or #where() and it is 1 database query.
I'm trying to use:
before_action do
only [:new, :edit] { get_referrer }
end
...
private def get_referrer
@referrer = Referrer.all("ORDER BY name ASC")
end
But I get:
In src/controllers/prospect_controller.cr:73:7
73 | @referrer = referrer
^--------
Error: can't infer the type of instance variable '@referrer' of ProspectController
The type of a instance variable, if not declared explicitly with
`@referrer : Type`, is inferred from assignments to it across
the whole program.
The assignments must look like this:
1. `@referrer = 1` (or other literals), inferred to the literal's type
2. `@referrer = Type.new`, type is inferred to be Type
3. `@referrer = Type.method`, where `method` has a return type
annotation, type is inferred from it
4. `@referrer = arg`, with 'arg' being a method argument with a
type restriction 'Type', type is inferred to be Type
5. `@referrer = arg`, with 'arg' being a method argument with a
default value, type is inferred using rules 1, 2 and 3 from it
6. `@referrer = uninitialized Type`, type is inferred to be Type
7. `@referrer = LibSome.func`, and `LibSome` is a `lib`, type
is inferred from that fun.
8. `LibSome.func(out @referrer)`, and `LibSome` is a `lib`, type
is inferred from that fun argument.
Other assignments have no effect on its type.
can't infer the type of instance variable '@referrer' of ProspectController
referrer = Referrer.all
, it works, but, then, how do I pass it to the view? (I wanted to add a blank option)
@referrer.reverse! << [nil, ""]; @referrer.reverse!
Ah, neither this works:
@date = "#{@prospect.date.to_s("%Y-%m-%d")}" unless @prospect.date.nil?
It says:
01:21:57 watch.run (Info) Building...
Showing last frame. Use --error-trace for full trace.
In src/controllers/prospect_controller.cr:23:31
23 | @date = "#{@prospect.date.to_s("%Y-%m-%d")}" unless @prospect.date.nil?
^---
Error: no overload matches 'Nil#to_s' with type String
Overloads are:
- Nil#to_s(io : IO)
- Nil#to_s()
- Object#to_s(io : IO)
- Object#to_s()
I dunno what's wrong in that last one. I am, clearly, telling it to assign that in unless date isn't nil.
I'll try the ternary operator...
Nope; doesn't work:
def edit
if date = @prospect.date
@date = @prospect.date.to_s("%Y-%m-%d")
end
Error:
[renich@introdesk rafita]$ amber w
2021-02-18T03:50:13.390177Z INFO - watch.run: Building...
09:50:13 watch.run (Info) Building...
Showing last frame. Use --error-trace for full trace.
In src/controllers/prospect_controller.cr:23:29
23 | @date =@prospect.date.to_s("%Y-%m-%d")
^---
Error: no overload matches 'Nil#to_s' with type String
Overloads are:
- Nil#to_s(io : IO)
- Nil#to_s()
- Object#to_s(io : IO)
- Object#to_s()
2021-02-18T03:50:17.208579Z INFO - watch.run: Compile time errors detected, exiting...
09:50:17 watch.run (Info) Compile time errors detected, exiting...
if date = @prospec.date
@date = date
end
I'll try that oneif date = @prospec.date @date = date end
With:
def edit
if date = prospect.date
@date = date
render "edit.slang"
end
end
I get:
10:59:58 watch.run (Info) Building...
Showing last frame. Use --error-trace for full trace.
In src/controllers/prospect_controller.cr:23:7
23 | @date = date
^----
Error: can't infer the type of instance variable '@date' of ProspectController
The type of a instance variable, if not declared explicitly with
`@date : Type`, is inferred from assignments to it across
the whole program.
The assignments must look like this:
1. `@date = 1` (or other literals), inferred to the literal's type
2. `@date = Type.new`, type is inferred to be Type
3. `@date = Type.method`, where `method` has a return type
annotation, type is inferred from it
4. `@date = arg`, with 'arg' being a method argument with a
type restriction 'Type', type is inferred to be Type
5. `@date = arg`, with 'arg' being a method argument with a
default value, type is inferred using rules 1, 2 and 3 from it
6. `@date = uninitialized Type`, type is inferred to be Type
7. `@date = LibSome.func`, and `LibSome` is a `lib`, type
is inferred from that fun.
8. `LibSome.func(out @date)`, and `LibSome` is a `lib`, type
is inferred from that fun argument.
Other assignments have no effect on its type.
can't infer the type of instance variable '@date' of ProspectController
def edit
if date = prospect.date
date = date.to_s("%Y-%m-%d")
@date = date
render "edit.slang"
end
end
Like I said, this builds:
def edit
if date = prospect.date
date = date.to_s("%Y-%m-%d")
render "edit.slang"
end
end
But I cannot use either: value=date
or value="#{date}"
@date : String?
somewhere
prob just need to add like
@date : String?
somewhere
Hah! That worked!
Hi @eliasjpr,
In order to keep the project healthy we would like to onboard New maintainers to Amber Framework
I have a suggestion about that, at least I hope it could work. amber
is listed in the-benchmarker/web-frameworks#3858, I hope maintainers could be interested by amber
if it come on the first place (I take care of this). I can see that amber
, at least master branch is working (for the benchmark) on 0.36
.
There is 2 solutions to allow me promote crystal
and amber
@eliasjpr @drujensen I apologize for being mostly absent for 2 years. My work load has been insane.
I'm pretty sure that Crystal is going to reach 1.0 very soon, and there are more and more companies every year using it.
We're still using crystal and a slightly older version of amber at work. Unfortunately our needs don't overlap a lot with most peoples use of a web framework so we haven't pushed that code up.
Anyway I just want to say to all the contributors that it's been amazing working with you and I really hope we can keep this project going even if its just maintaining compatibility with the most recent releases of crystal which will hopefully be 1.0. :)